ElephantQ
Background jobs for Python. Powered by the Postgres you already have.
Quickstart
pip install elephantq
# jobs.py
from elephantq import ElephantQ
app = ElephantQ(database_url="postgresql://localhost/myapp")
@app.job(max_retries=3)
async def send_welcome(to: str):
print(f"Sending welcome email to {to}")
# enqueue from anywhere in your app
await app.enqueue(send_welcome, to="dev@example.com")
# set up tables and start processing
elephantq setup
elephantq start --concurrency 4
Four steps. Define a job, enqueue it, set up the database, start a worker.
Local dev without Postgres? Use SQLite:
ElephantQ(database_url='local.db'). For production, always use PostgreSQL.
Transactional enqueue
Enqueue a job inside your database transaction. If the transaction rolls back, the job never existed.
async with pool.acquire() as conn:
async with conn.transaction():
await conn.execute("INSERT INTO orders ...")
await app.enqueue(send_invoice, connection=conn, order_id=order_id)
# Both commit together, or neither does
No Redis queue can do this. Your job and your data land in the same commit. If something fails halfway through, both roll back. No stale jobs, no ghost tasks, no cleanup scripts.
Why ElephantQ
Most Python job queues force you to run Redis or RabbitMQ alongside your database. That's another service to deploy, monitor, back up, and debug when things go wrong at 3am.
ElephantQ uses your existing PostgreSQL. One dependency. One place your data lives. One thing to back up.
| Feature | ElephantQ | Celery | RQ |
|---|---|---|---|
| No Redis dependency | Yes | No | No |
| Async native | Yes | Partial | No |
| Transactional enq. | Yes | No | No |
| Setup complexity | Low | High | Medium |
| Built-in dashboard | Yes | No (Flower) | No |
| Dead-letter queue | Yes | No | No |
Features
- Retries with backoff -- configurable delays, exponential backoff, per-attempt delay lists
- Dead-letter queue -- failed jobs preserved for inspection and manual retry
- Job priorities -- lower number = higher priority, processed first
- Scheduled jobs -- run at a specific time or after a delay
- Recurring jobs -- cron-based periodic tasks with
@app.periodic(cron="0 * * * *") - Transactional enqueue -- atomic with your database writes
- Multiple queues -- route jobs by type, run dedicated workers per queue
- Middleware hooks --
before_job,after_job,on_errorfor logging, metrics, tracing - Worker heartbeat -- auto-detect crashed workers, requeue their jobs
- Job results -- store and retrieve return values from completed jobs
- Deduplication -- prevent duplicate jobs with
dedup_keyorunique=True - CLI --
setup,start,status,workers, dead-letter management - Dashboard -- web UI for monitoring queues, workers, and job state
Dashboard
Monitor queues, workers, retries, and system health from a built-in web UI.
pip install elephantq[dashboard]
elephantq dashboard
Install
pip install elephantq # core (Postgres backend)
pip install elephantq[full] # everything below
pip install elephantq[sqlite] # SQLite backend for local dev
pip install elephantq[scheduling] # cron-based recurring jobs
pip install elephantq[dashboard] # web dashboard
pip install elephantq[monitoring] # Prometheus metrics
pip install elephantq[webhooks] # webhook delivery + signing
When NOT to use ElephantQ
- You need 10k+ jobs/sec sustained throughput. PostgreSQL row locking has limits. Redis-backed queues like Celery or Arq are built for this.
- You need cross-language consumers. ElephantQ is Python-only. If your workers are in Go or Node, use RabbitMQ or a similar broker.
- You're not using PostgreSQL. The production backend requires PostgreSQL. If your stack is MySQL or MongoDB, this isn't for you.
- You need DAG-based workflow orchestration. ElephantQ handles individual jobs, not pipelines. Look at Prefect or Airflow.
Documentation
- Quickstart
- FastAPI integration
- Jobs and concepts
- Production checklist
- Deployment
- CLI reference
- API reference
License
MIT
Metadata
Release files for elephantq 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| elephantq-0.3.1.tar.gz | 108.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| elephantq-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 233.4 kB
Release files / elephantq-0.3.1.tar.gz
| Download URL | elephantq-0.3.1.tar.gz |
|---|---|
| Size | 108.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
194f37cca4f30a655e87f2c9dc8e73231d8a4667c212563de7cacd5de71679f2
|
|
BLAKE2b-256 checksum How to use checksums |
e56de52609421b5aab3afeb4b1884dadeb496b8dddefe934711339300e0ad8a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 14, 2026.
Transparency logRelease files / elephantq-0.3.1-py3-none-any.whl
| Download URL | elephantq-0.3.1-py3-none-any.whl |
|---|---|
| Size | 124.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
93cac67640c24333c2ad2f0e5843902b78f8080a89d005a6cd95fbefad09caab
|
|
BLAKE2b-256 checksum How to use checksums |
eab90ceb631ea2617e1e3633a1c651ca66661581f8b4f7e8729fffedf310ac00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 14, 2026.
Transparency log