Skip to main content

Run Litestar applications with Granian while preserving Litestar startup, shutdown, logging, and server integrations.

Project description

Litestar Granian

Run Litestar applications with Granian while preserving Litestar startup, shutdown, logging, and server integrations.

Install

python -m pip install litestar-granian

Run your first app

Save this as example.py:

from litestar import Litestar, get

from litestar_granian import GranianPlugin


@get("/")
async def hello() -> dict[str, str]:
    return {"hello": "world"}


app = Litestar(route_handlers=[hello], plugins=[GranianPlugin()])

Start the server:

litestar --app example:app run

Open http://127.0.0.1:8000/ in a browser, or run:

curl http://127.0.0.1:8000/

You should receive:

{"hello":"world"}

Press Ctrl+C in the server terminal to stop it.

Why use this plugin?

  • Keep the familiar litestar run command while using Granian.
  • Start Litestar server integrations once around all Granian workers.
  • Configure workers, protocols, logging, metrics, and static files from one CLI.

What the plugin changes

GranianPlugin() replaces Litestar's standard run command with a Granian-backed command. It does not change commands that start another ASGI server directly.

Run the complete command reference with:

litestar --app example:app run --help
Optional event loops

The default installation uses Granian's standard loop selection and installs no optional event loop. Install and select one integration at a time:

python -m pip install "litestar-granian[uvloop]"
litestar --app example:app run --loop uvloop

On supported platforms, use the matching rloop or winloop extra and pass --loop rloop or --loop winloop.

Next steps

  • Quickstart — repeat the first run and learn what to check.
  • Configuration — choose bindings, workers, protocols, TLS, reload, and event loops.
  • Logging and metrics — see how Granian automatically matches Litestar's formatter or accepts a complete override.
  • Deployment — forward signals and verify clean shutdown.
  • CLI reference — browse every option and environment variable.

License

litestar-granian is distributed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

litestar_granian-0.16.0b1.tar.gz (221.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

litestar_granian-0.16.0b1-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

File details

Details for the file litestar_granian-0.16.0b1.tar.gz.

File metadata

  • Download URL: litestar_granian-0.16.0b1.tar.gz
  • Upload date:
  • Size: 221.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for litestar_granian-0.16.0b1.tar.gz
Algorithm Hash digest
SHA256 1ad6b23b7f54dbbea3849ea5017392fcedc47ffea572b0ec5263aa4a47026f5c
MD5 8c02808effdbca677de49567a00e8ce9
BLAKE2b-256 264648fabed2d82aadc98e02c481a7fc79f606d0e903416bb56319a219f4ff02

See more details on using hashes here.

Provenance

The following attestation bundles were made for litestar_granian-0.16.0b1.tar.gz:

Publisher: publish.yml on cofin/litestar-granian

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file litestar_granian-0.16.0b1-py3-none-any.whl.

File metadata

File hashes

Hashes for litestar_granian-0.16.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 54c3a22a1548f42cdfa5915e825a33f8ac299f27b2be3bcddaef4ddb55f31832
MD5 6677403bd73374e19ae11f8ff79adc4a
BLAKE2b-256 a508390ee2981c2e591b5774ad687d7672396c5ccd0ccb560f5257a2c569f704

See more details on using hashes here.

Provenance

The following attestation bundles were made for litestar_granian-0.16.0b1-py3-none-any.whl:

Publisher: publish.yml on cofin/litestar-granian

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page