nodus-queue
Distributed job queue with Dead Letter Queue, delayed jobs, in-flight tracking, and visibility-timeout recovery. Redis backend for multi-instance production; in-memory fallback for dev and tests. Zero hard dependencies beyond tenacity.
Install
pip install nodus-queue # core + in-memory backend
pip install "nodus-queue[redis]" # + Redis backend
Quickstart
from nodus_queue import QueueJobPayload, get_queue, reset_queue
# In dev/test — in-memory backend (automatic when REDIS_URL is unset)
q = get_queue()
job = QueueJobPayload(job_id="run-123", task_name="agent.run")
q.enqueue(job)
# Worker side
job = q.dequeue(timeout=5) # blocks up to 5 seconds
if job:
try:
# ... process job ...
q.ack(job.job_id) # remove from in-flight
except Exception as e:
q.fail(job.job_id, str(e)) # move to DLQ
Redis backend
REDIS_URL=redis://localhost:6379/0
from nodus_queue import get_queue
q = get_queue() # picks up REDIS_URL automatically
Delayed jobs
# Schedule a job to run after 30 seconds
q.enqueue_delayed(job, delay_seconds=30)
# Promote ready jobs (call periodically in Redis mode)
count = q.process_delayed_jobs()
Crash recovery
# On worker startup — re-enqueue jobs stuck in-flight for > 5 minutes
q.requeue_stale_jobs(timeout_seconds=300)
Dead Letter Queue
depth = q.get_dlq_depth()
q.drain_dead_letters() # clear all
q.remove_dead_letter("job-id-123") # remove one
Optional Prometheus metrics
from prometheus_client import CollectorRegistry, Counter, Gauge
from nodus_queue import QueueMetrics, get_queue
REGISTRY = CollectorRegistry()
enq = Counter("queue_enqueue_total", "...", ["backend", "outcome"], registry=REGISTRY)
class MyMetrics(QueueMetrics):
def on_enqueue(self, backend, outcome):
enq.labels(backend=backend, outcome=outcome).inc()
# override other hooks as needed
q = get_queue(metrics=MyMetrics())
Backend change callback
def on_change(event: str, payload: dict) -> None:
print(f"Queue backend changed: {event} {payload}")
q = get_queue(on_backend_change=on_change)
Environment variables
| Variable | Default | Purpose |
|---|---|---|
REDIS_URL |
— | Redis connection URL |
NODUS_QUEUE_NAME |
nodus:jobs |
Key prefix for all queue Redis keys |
NODUS_QUEUE_MAXSIZE |
100 |
Hard capacity limit |
NODUS_REQUIRE_REDIS |
false |
Fail on startup if Redis is unavailable |
EXECUTION_MODE |
thread |
distributed requires REDIS_URL |
ENV |
— | production/prod requires REDIS_URL |
TESTING / TEST_MODE |
— | Auto-select in-memory backend |
Extracted from
AINDY/core/distributed_queue.py in the A.I.N.D.Y. runtime.
Metadata
Release files for nodus-queue 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nodus_queue-0.1.0.tar.gz | 18.9 kB | Without provenance | Details for nodus_queue-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nodus_queue-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for nodus_queue-0.1.0-py3-none-any.whl |
Total release size: 34.5 kB
Release files / nodus_queue-0.1.0.tar.gz
| Download URL | nodus_queue-0.1.0.tar.gz |
|---|---|
| Size | 18.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
584306995aac7dd353e060ded496c76ca9e093d2e66b8a1020c64f3814726e32
|
|
BLAKE2b-256 checksum How to use checksums |
a06d28e6cd5e51caf3e9f1f06dd4b383ed3c57a93132b718d71188c9c392b0e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Release files / nodus_queue-0.1.0-py3-none-any.whl
| Download URL | nodus_queue-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
79e3c0d4964efbdb1e3da213f9402e48af13afd7535a8d6179667f32a573d62a
|
|
BLAKE2b-256 checksum How to use checksums |
912a0b4482b742f23d88e9d26a7df19d8a4540aae3cad375f1f87a9d307db1af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Security for nodus-queue 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.