Skip to main content

Durable local queues for Python, with persistent retry state powered by Tenacity.

Project description

localqueue

Tests CodeQL PyPI version Coverage

localqueue is a small durable queue for one machine. It stores work on the local filesystem by default and keeps retry state with Tenacity.

Use it when the work can stay local and you want one of these outcomes:

  • accept work now and perform the side effect later on the same machine
  • inspect failed jobs and replay them from the terminal
  • keep retry budgets across process restarts without adding a broker

It fits scripts, CLI tools, cron jobs, and small Python workers that share one local store.

localqueue queue exec emails -- python scripts/send_email.py
from localqueue import PersistentQueue, QoS, QueueSpec, persistent_worker

spec = (
    QueueSpec("emails")
    .with_qos(QoS.AT_LEAST_ONCE)
    .with_retry(max_retries=3)
    .with_dead_letter_on_failure(False)
    .with_release_delay(30.0)
    .with_circuit_breaker(threshold=3, cooldown=30.0)
    .with_dead_letter_queue()
)

queue = PersistentQueue(spec=spec)
worker_config = queue.build_worker_config()
queue.put({"to": "user@example.com"})

@persistent_worker(queue, config=worker_config)
def send_email(job: dict[str, str]) -> None:
    deliver(job["to"])

Reuse same config for multiple queue names with with_name(...), or override the spec name directly in the constructor:

base = QueueSpec("orders.base").with_qos(QoS.AT_LEAST_ONCE)

payments = PersistentQueue(spec=base.with_name("orders.payment"))
refunds = PersistentQueue("orders.refund", spec=base)

Full docs live at brunoportis.github.io/localqueue. The source docs are in docs/.

Container examples live in examples/docker-compose/. Step-by-step reproducible docs for them live in docs/examples.md.

Start with docs/use-cases.md if you want the shortest path to deciding whether the project fits your workflow.

For development and release workflow details, see docs/develop.md.

Install

pip install localqueue

For the CLI:

pip install "localqueue[cli]"

For the optional LMDB backend:

pip install "localqueue[lmdb]"

Running with Docker

The image is also published on GitHub Container Registry:

docker pull ghcr.io/brunoportis/localqueue:latest
docker run --rm ghcr.io/brunoportis/localqueue:latest --help

When not to use

localqueue is not a distributed broker. If you need multi-host coordination, high write concurrency, managed retention, or strict cross-service ordering, use a system designed for that operating model.

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

localqueue-0.5.0.tar.gz (188.3 kB view details)

Uploaded Source

Built Distribution

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

localqueue-0.5.0-py3-none-any.whl (88.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: localqueue-0.5.0.tar.gz
  • Upload date:
  • Size: 188.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for localqueue-0.5.0.tar.gz
Algorithm Hash digest
SHA256 8243860bb590b76a5c1a6e08123ef0c925722c0c38a0597593cccb45c4a3698c
MD5 226089258ec9ea04a69933503b02e586
BLAKE2b-256 02fd148f989aa63d7225bca8a5a4334e35be6c62de5421826182fb1eec52fa73

See more details on using hashes here.

File details

Details for the file localqueue-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: localqueue-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 88.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for localqueue-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d86b76a69768bf80c1c7ce2a7377d1cde8b390d65dd890b7cc092879650eeb95
MD5 7c7a52cf4209cc71a61216e3ae6958b0
BLAKE2b-256 955e04a25859ad46aed9d03ca4dc22304100509b5496532ec385144323812b26

See more details on using hashes here.

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