Skip to main content

Litestar Queues

PyPI Python License CI Docs

Litestar Queues lets a Litestar application persist work, run it in a worker, and inspect the result. Use it for work that should outlive the request that started it: sending email, importing files, refreshing reports, or calling a slow service.

Quickstart

Install the package:

pip install litestar-queues

Create app.py:

from litestar import Litestar, post
from litestar.di import NamedDependency

from litestar_queues import QueueConfig, QueuePlugin, QueueService, task


@task("accounts.sync", queue="accounts", timeout=30)
async def sync_account(account_id: str) -> dict[str, str]:
    return {"account_id": account_id, "status": "synced"}


@post("/accounts/{account_id:str}/sync")
async def create_sync_job(
    account_id: str,
    queue_service: NamedDependency[QueueService],
) -> dict[str, str]:
    result = await queue_service.enqueue(sync_account, account_id)
    return {"task_id": str(result.id), "status": result.status or "pending"}


app = Litestar(
    route_handlers=[create_sync_job],
    plugins=[QueuePlugin(config=QueueConfig())],
)

Run the application:

LITESTAR_APP=app:app litestar run --reload

Enqueue a task:

curl -X POST http://127.0.0.1:8000/accounts/acct-123/sync

The response contains a task ID and an initial status. The default in-memory queue and in-app worker are ideal for this first run.

Production boundary

Choose where tasks are stored separately from where they run. The default memory backend stores tasks in one Python process. If the web app and worker run in separate processes, use a shared backend such as SQLSpec, Advanced Alchemy, Redis, or Valkey. Use standalone workers when the web app and task workers must scale separately. Cloud Run runs tasks; it does not store them.

Next steps

Litestar Queues supports Python 3.10 through 3.14 and is licensed under MIT.

Download files

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

Source Distribution

litestar_queues-0.5.0.tar.gz (829.6 kB view details)

Uploaded Source

Built Distribution

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

litestar_queues-0.5.0-py3-none-any.whl (243.1 kB view details)

Uploaded Python 3

File details

Details for the file litestar_queues-0.5.0.tar.gz.

File metadata

  • Download URL: litestar_queues-0.5.0.tar.gz
  • Upload date:
  • Size: 829.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for litestar_queues-0.5.0.tar.gz
Algorithm Hash digest
SHA256 a2d0073443bf4b8819568833bbd8523ed65cc29cd413c7b3cd964d091d304ec4
MD5 9e1e9788e253ecbb80d1ae331da17132
BLAKE2b-256 c4e5d248e1422f3fcf042669e948c7a2b24aec17391fa15b1764e103bb0b88aa

See more details on using hashes here.

Provenance

The following attestation bundles were made for litestar_queues-0.5.0.tar.gz:

Publisher: publish.yml on cofin/litestar-queues

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_queues-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: litestar_queues-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 243.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for litestar_queues-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 40f98f4d136370f4aed2a2345ff8da65d90bca82913274d529fc92fad2151669
MD5 e074c14235d2208d79e3bc6c20779d02
BLAKE2b-256 ccf918dbc38ed5f9bfdccc8fa936fe106848ed498294f101e4a6365cd19ecf00

See more details on using hashes here.

Provenance

The following attestation bundles were made for litestar_queues-0.5.0-py3-none-any.whl:

Publisher: publish.yml on cofin/litestar-queues

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 Sentry Error logging StatusPage Status page