Lapinq 🐇
A lightweight task queue with PostgreSQL backend — replacing Celery + RabbitMQ with a single container.
Why Lapinq?
Celery + RabbitMQ is powerful but heavyweight for many projects. Lapinq replaces both with a single container:
- No separate broker — PostgreSQL handles both storage and queueing
- No separate worker daemon — Python or Rust worker built in
- Real-time dashboard — Monitor queues and tasks out of the box
- Configurable concurrency — Control exactly how many tasks run simultaneously
Quick Start
from lapinq import TaskQueue
tasks = TaskQueue(server_url="http://localhost:8001", queue_name="video")
@tasks.task(name="transcode_video")
def transcode_video(video_id: int, codec: str):
print(f"Transcoding video {video_id} to {codec}")
# Enqueue the task — runs on the worker
# Use .queue() for sync clients or .aqueue() for async clients
ref = transcode_video.queue(video_id=1, codec="h264")
print(f"Task ID: {ref.task_id}")
# Optional: wait for result (polling)
result = ref.wait(timeout=30)
print(result["status"], result.get("result"))
Installation
pip install lapinq
Or from source:
git clone https://github.com/rroblf01/lapinq.git
cd lapinq
pip install maturin
maturin develop
Usage
1. Start PostgreSQL
docker run -d --name lapinq-pg \
-e POSTGRES_USER=lapinq \
-e POSTGRES_PASSWORD=secret \
-e POSTGRES_DB=lapinq \
-p 5432:5432 \
postgres:16-alpine
2. Start the server
lapinq server --host 0.0.0.0 --port 8001
3. Start a worker
# Python worker (development)
lapinq worker --concurrency 4
# Or Rust worker (production, ~20x faster polling)
lapinq-worker --database-url postgresql://lapinq:secret@localhost:5432/lapinq --concurrency 4
4. Open the dashboard
Visit http://localhost:8001/dashboard to monitor queues and tasks in real time.
Architecture
┌──────────────┐ HTTP ┌──────────────────┐ SQL ┌────────────┐
│ Web App │ ──────────► │ Lapinq Server │ ─────────► │ PostgreSQL │
│ (FastAPI/ │ │ Server │ │ │
│ Django) │ │ (Starlette) │ │ Tasks │
│ │ │ + Dashboard │ │ │
└──────────────┘ └────────┬─────────┘ └─────▲──────┘
│ │
│ spawns │ polls
▼ │
┌──────────────────┐ │
│ Worker │───────────────────►│
│ (Rust or Python) │ FOR UPDATE
│ │ SKIP LOCKED
└──────────────────┘
Features
| Feature | Status |
|---|---|
@tasks.task() decorator API |
✅ |
| PostgreSQL queue storage | ✅ |
| REST API for task management | ✅ |
| Real-time HTMX dashboard | ✅ |
| Python native worker | ✅ |
| Rust worker (high performance) | ✅ |
| Configurable concurrency | ✅ |
| Task timeout | ✅ |
| Task cancellation & requeue | ✅ |
| Multiple queues | ✅ |
| CORS support | ✅ |
| Graceful shutdown | ✅ |
| Docker Compose | ✅ |
| GitHub Actions CI/CD | ✅ |
| MkDocs documentation | ✅ |
| Task metadata / tags | ✅ |
| Task progress tracking | ✅ |
| Batch enqueue | ✅ |
| Configurable retry policies | ✅ |
| Default TTL per queue | ✅ |
| Webhook callbacks | ✅ |
TaskRef — awaitable results |
✅ |
Manual retry (RetryError exception) |
✅ |
| CLI task management | ✅ |
| Cron-based periodic scheduler | ✅ |
Documentation
Full documentation is available at https://rroblf01.github.io/lapinq
Docker
docker compose up -d
This starts:
- PostgreSQL — database engine
- Server — lapinq REST API + dashboard
- Rust Worker — high-performance task executor (requires
--profile rust)
Development
uv sync
uv run maturin develop
uv run pytest
Roadmap
✅ Complete
@tasks.task()decorator API, PostgreSQL queue, REST API, WebSocket dashboard- Python + Rust workers, configurable concurrency, task timeout, cancellation
- Multiple queues, CORS, graceful shutdown, Docker Compose, CI/CD
- Task history, retries with backoff, stale task reaper, scheduled tasks
- Priority queues, async client, Dead Letter Queue, worker heartbeat
- Auth (API key), rate limiting, Prometheus metrics, structured logging
- PyPI package, i18n docs (EN + ES), TTL support, Rust executor (PyO3)
- Task metadata / tags, progress tracking, batch enqueue
- Configurable retry policies, default TTL per queue, webhook callbacks
- TaskRef (awaitable results), manual Retry exception
- CLI task management (
lapinq task list|get|cancel|requeue) - Cron-based periodic scheduler (
lapinq server --scheduler) - Schema migrations, CHANGELOG.md,
abi3wheels
🟢 Future
- Task chaining / workflows (
chain,group,chord) - Distributed rate limiting (Redis-backed)
- OpenTelemetry tracing
- Pre/post task middleware hooks
- CONTRIBUTING.md — development guide
- Code coverage in CI — upload to Codecov
Database Schema
All queue state lives in a single table lapinq_tasks:
| Column | Type | Default | Description |
|---|---|---|---|
id |
UUID |
gen_random_uuid() |
Primary key |
queue_name |
TEXT |
— | Queue this task belongs to |
task_name |
TEXT |
— | Name of the function to call |
module_path |
TEXT |
— | Python module to import |
args |
JSONB |
[] |
Positional arguments |
kwargs |
JSONB |
{} |
Keyword arguments |
status |
TEXT |
pending |
One of: pending, running, completed, failed, cancelled, expired |
result |
TEXT |
— | Serialized return value (completed tasks) |
error |
TEXT |
— | Error message (failed tasks) |
attempts |
INT |
0 |
Number of execution attempts |
max_retries |
INT |
3 |
Max retries before marking as failed |
priority |
INT |
0 |
Higher values claim first |
metadata |
JSONB |
{} |
Arbitrary key-value pairs |
progress |
INT |
0 |
Progress percentage (0–100) |
retry_delay |
FLOAT |
— | Fixed delay between retries (seconds) |
retry_backoff |
BOOLEAN |
true |
Exponential backoff |
webhook_url |
TEXT |
— | URL called on completion/failure |
created_at |
TIMESTAMPTZ |
now() |
Creation timestamp |
scheduled_at |
TIMESTAMPTZ |
now() |
Earliest allowed claim time |
started_at |
TIMESTAMPTZ |
— | When a worker claimed the task |
completed_at |
TIMESTAMPTZ |
— | When the task finished (completed or failed) |
last_heartbeat |
TIMESTAMPTZ |
— | Worker periodic heartbeat |
worker_id |
TEXT |
— | Which worker claimed the task |
Key indexes:
idx_tasks_status— filtering by status + created_at orderidx_tasks_scheduled— efficient pending-task polling (WHERE status = 'pending')idx_tasks_pending_priority— priority-aware claiming
Environment Variables
| Variable | Default | Used by | Purpose |
|---|---|---|---|---|
| DATABASE_URL | postgresql://localhost:5432/lapinq | server, worker, execute | PostgreSQL connection string |
| LAPINQ_API_KEY | (none — auth disabled) | server | Enables X-API-Key auth middleware |
| LAPINQ_RATE_LIMIT | 0 (disabled) | server | Max requests per minute per IP |
| LAPINQ_MAX_PAYLOAD_SIZE | 102400 (100KB) | server | Max JSON payload size for enqueue |
| LAPINQ_POOL_SIZE | 10 | server, worker | PostgreSQL connection pool size |
| LAPINQ_HEARTBEAT_INTERVAL | 15.0 | worker | Seconds between worker heartbeats |
| LAPINQ_CORS_ORIGINS | * | server | Comma-separated allowed CORS origins |
| LAPINQ_JSON_LOG | 0 (text logging) | server, worker, execute | Set to 1 for structured JSON |
| LAPINQ_LOG_LEVEL | INFO | server, worker, execute | Log level override |
Task Lifecycle
enqueue ──► pending ──► running ──► completed
│ │
│ ├── result captured
│ └── status = 'completed'
│
└── (scheduled_at in future)
└── claimed after scheduled_at
running ──► fail (attempts < max_retries)
└── pending (scheduled with backoff)
running ──► fail (attempts >= max_retries)
└── failed (stored with error)
running ──► worker crash / timeout
└── pending (recovered by stale-task reaper)
failed ──► requeue
└── pending (reset attempts = 0)
Retry backoff schedule: 10s, 30s, 60s, 300s, 600s (cap at 600s).
License
MIT
Release files for lapinq 1.3.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 | |
|---|---|---|---|
| lapinq-1.3.0.tar.gz | 211.9 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| lapinq-1.3.0-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
| lapinq-1.3.0-cp310-abi3-win32.whl | CPython 3.10 | abi3 | Windows x86-32 | Details |
| lapinq-1.3.0-cp310-abi3-musllinux_1_2_x86_64.whl | CPython 3.10 | abi3 | Linux musl 1.2+ x86-64 | Details |
| lapinq-1.3.0-cp310-abi3-musllinux_1_2_aarch64.whl | CPython 3.10 | abi3 | Linux musl 1.2+ ARM64 | Details |
| lapinq-1.3.0-cp310-abi3-manylinux_2_28_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.28+ x86-64 | Details |
| lapinq-1.3.0-cp310-abi3-manylinux_2_28_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.28+ ARM64 | Details |
| lapinq-1.3.0-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details |
| lapinq-1.3.0-cp310-abi3-macosx_10_12_x86_64.whl | CPython 3.10 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 2.4 MB
Release files / lapinq-1.3.0.tar.gz
| Download URL | lapinq-1.3.0.tar.gz |
|---|---|
| Size | 211.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f83368fca0b6a95099a25064376b8a6f555c656a620089c16165c23a3ceaf855
|
|
BLAKE2b-256 checksum How to use checksums |
7d5d07e3e2ca67e71ca532934ce7d6cc877714a504b74fc053bec47b276e955b
|
| 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 May 26, 2026.
Transparency logRelease files / lapinq-1.3.0-cp310-abi3-win_amd64.whl
| Download URL | lapinq-1.3.0-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 167.0 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
743345befdef8b8ae9cd51e4f482273a460ea580f6e4a3838da7381cd5fbea5a
|
|
BLAKE2b-256 checksum How to use checksums |
9dd71b38562979a49399292c58403891fd0c17f25af0f8c33e94eb49cdca3577
|
| 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 May 26, 2026.
Transparency logRelease files / lapinq-1.3.0-cp310-abi3-win32.whl
| Download URL | lapinq-1.3.0-cp310-abi3-win32.whl |
|---|---|
| Size | 153.6 kB |
| Tags | CPython 3.10 Windows x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
e4f5fde477cbec17782ff1273707aa4824952b5f6b23e562915d9c5caa6cc041
|
|
BLAKE2b-256 checksum How to use checksums |
d0c358af831115819fabf15e36ff50ceb2d250d91a09024998a0ce42856353ec
|
| 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 May 26, 2026.
Transparency logRelease files / lapinq-1.3.0-cp310-abi3-musllinux_1_2_x86_64.whl
| Download URL | lapinq-1.3.0-cp310-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 368.5 kB |
| Tags | CPython 3.10 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
6c1bb150ba23cf6d9c42318959ce5ffcde5eb7a7c6fa59bc421b13a065bf2a2a
|
|
BLAKE2b-256 checksum How to use checksums |
73678d0f87bc32d78fe1d900565a3bd5e97687dba25bb3b95dcf4a8b106f459d
|
| 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 May 26, 2026.
Transparency logRelease files / lapinq-1.3.0-cp310-abi3-musllinux_1_2_aarch64.whl
| Download URL | lapinq-1.3.0-cp310-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 355.3 kB |
| Tags | CPython 3.10 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
57d1c78c6ebf178c2163562e7ccf9ac002b34d827128a3a06c62d170b3d9639e
|
|
BLAKE2b-256 checksum How to use checksums |
8f1b6309bad8753bb723089df4c9ca27efa4303bce803ff8fb018ad146f9e045
|
| 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 May 26, 2026.
Transparency logRelease files / lapinq-1.3.0-cp310-abi3-manylinux_2_28_x86_64.whl
| Download URL | lapinq-1.3.0-cp310-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 298.3 kB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
4acb5aeca7f4e9efb9ea632f55875ae89c52a30f6a4effe24abbedc977c13ec5
|
|
BLAKE2b-256 checksum How to use checksums |
8e8932a879d30144abf9a1979d0727e5fe79786d68b95fb0e9de46a48a4a8956
|
| 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 May 26, 2026.
Transparency logRelease files / lapinq-1.3.0-cp310-abi3-manylinux_2_28_aarch64.whl
| Download URL | lapinq-1.3.0-cp310-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 289.9 kB |
| Tags | CPython 3.10 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
6f9c0d89e54162aeb34acc65cd11af38f63a2a4e2d085103dd020c90b48f160d
|
|
BLAKE2b-256 checksum How to use checksums |
f651191f35d50f780e1dd2c5b2fb221b52d0a0cde9c66ed76a33e354249d6d65
|
| 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 May 26, 2026.
Transparency logRelease files / lapinq-1.3.0-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | lapinq-1.3.0-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 265.4 kB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
259ac4013e029f553e57432f76621d1405d122ef92d2821f87449481db99888c
|
|
BLAKE2b-256 checksum How to use checksums |
c211a02a2ed32226b2a3e10ed63d5924adff480234bfbda5f0c5faebec948898
|
| 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 May 26, 2026.
Transparency logRelease files / lapinq-1.3.0-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | lapinq-1.3.0-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 268.3 kB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
89ef2366310a6aaa5501c65e45eea20d86c27e42bab9dad47c3b37f26a32762f
|
|
BLAKE2b-256 checksum How to use checksums |
a4c473b6e8494351e0059759b2966dd1cad3337c64fc514ab9c45959d979f1d6
|
| 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 May 26, 2026.
Transparency log