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.0b2.tar.gz (223.0 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.0b2-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: litestar_granian-0.16.0b2.tar.gz
  • Upload date:
  • Size: 223.0 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.0b2.tar.gz
Algorithm Hash digest
SHA256 ab9a4b74871d318cb2c0fe975c38607496dc2547bcf284ddf0f89e49f5782fb1
MD5 edb0f6f0ad9fb173f54739592d3bab56
BLAKE2b-256 79e0bd9a747c056d61a98b678dba345c5cb9d3b2b93e742f479298d6b7bf9917

See more details on using hashes here.

Provenance

The following attestation bundles were made for litestar_granian-0.16.0b2.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.0b2-py3-none-any.whl.

File metadata

File hashes

Hashes for litestar_granian-0.16.0b2-py3-none-any.whl
Algorithm Hash digest
SHA256 561ca9aca3754af792072485bcc99faad6c4d9d27f6fe09158720aaeecab2ffc
MD5 095871a43cbc96279b5308e4c2fbf746
BLAKE2b-256 554eaf24319cf616013ac798ed648760462e63c4e603cd505afa8ba36aeb3f9e

See more details on using hashes here.

Provenance

The following attestation bundles were made for litestar_granian-0.16.0b2-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