Async task queue library for Python — Redis and AWS SQS/Lambda backends
Project description
enqueuefy
Async task queue library for Python with Redis and AWS SQS/Lambda backends.
Installation
pip install enqueuefy
Quick start — Redis
server.py (worker process)
from enqueuefy import AIORedisConsumer
consumer = AIORedisConsumer(
broker_url="redis://localhost:6379",
modules=["myapp.tasks"],
)
queue = consumer.queue("default")
if __name__ == "__main__":
consumer.run()
tasks.py (define tasks)
from myapp.server import queue
@queue.task(retries=3, timeout=30)
async def send_email(to: str, subject: str):
...
@send_email.on_failure
async def on_send_failure(to: str, subject: str):
print(f"Failed to send email to {to}")
@send_email.on_timeout
async def on_send_timeout(to: str, subject: str):
print(f"Email to {to} timed out")
producer.py (enqueue tasks)
from myapp.tasks import send_email
await send_email.enqueue("user@example.com", subject="Hello")
Run the worker
python server.py --broker-url redis://localhost:6379 --queues default --max-concurrency 10
Quick start — AWS SQS / Lambda
server.py
from enqueuefy import AIOSQSLambdaConsumer
consumer = AIOSQSLambdaConsumer(
region_name="us-east-1",
aws_access_key_id="...",
aws_secret_access_key="...",
modules=["myapp.tasks"],
)
queue = consumer.queue("https://sqs.us-east-1.amazonaws.com/123456789/my-queue")
if __name__ == "__main__":
consumer.run() # generates Lambda handler files
tasks.py
from myapp.server import queue
@queue.task()
async def process_order(order_id: str):
...
Running server.py generates ready-to-deploy AWS Lambda handler files in sqs_lambda_handlers/.
CLI options (Redis worker)
| Flag | Default | Description |
|---|---|---|
--broker-url |
— | Redis connection URL |
--queues |
default |
Comma-separated queue names |
--max-concurrency |
10 |
Max concurrent tasks |
Features
- Async-first, built on
asyncio - Redis backend with at-least-once delivery and startup recovery of in-flight messages
- Per-task
retries,timeout,on_failure, andon_timeouthooks - SQS/Lambda backend that auto-generates Lambda handler files
- Distributed startup-requeue lock — safe for multi-pod Kubernetes deployments
Development
make test # run tests
make coverage # test with coverage report
make format # black + isort
make build # build distribution packages
make publish # upload to PyPI via twine
make publish-test # upload to TestPyPI
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file enqueuefy-0.0.1a1.tar.gz.
File metadata
- Download URL: enqueuefy-0.0.1a1.tar.gz
- Upload date:
- Size: 10.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7729792bbe482ca99fbddd47d378accdc3f1a414e95980284016d3f7cd27f07e
|
|
| MD5 |
d266778e97564acfec79be0b8661c967
|
|
| BLAKE2b-256 |
afb9fcb964a055d96defe30e6883b0f6cff17f9a9ea27dcf4e4ae28ab2ac6145
|
File details
Details for the file enqueuefy-0.0.1a1-py3-none-any.whl.
File metadata
- Download URL: enqueuefy-0.0.1a1-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31e91d45b1500bda35000683f6d1be5a387b27e3eac3444b47fa5184b2201fab
|
|
| MD5 |
87ac76ff956b4fbd768c64527a48c8a1
|
|
| BLAKE2b-256 |
d4ea523882f783882ee013f79c28b3ec7f74bda8784539be55ce514a21c39aa4
|