A modern, async-first, type-safe task queue for Python 3.12+. Inspired by Laravel's elegant queue system. Native FastAPI integration. Switch between multiple queue backends (Redis, PostgreSQL, MySQL, RabbitMQ, AWS SQS) with one config line. Automatic ORM serialization (SQLAlchemy, Django, Tortoise) using msgpack reduces payloads by 90%+. Features ACID guarantees, dead-letter queues, crash recovery, and real-time event streaming.
📊 Looking for a monitoring dashboard? Check out asynctasq-monitor – a beautiful real-time UI to monitor your tasks, workers, and queues.
- Async TasQ
- Built with asyncio from the ground up – No threading, no blocking operations on critical paths
- Native async/await support – Seamless integration with modern Python async code
- High concurrency – Process thousands of tasks concurrently with minimal resource usage
- Efficient I/O – Connection pooling for all database drivers
- msgpack encoding – Binary serialization that's faster and more compact than JSON
- Efficient binary handling – Native
use_bin_type=Truefor optimal bytes processing - Automatic ORM model handling – Pass SQLAlchemy, Django, or Tortoise models directly as task parameters. They're automatically serialized as lightweight references (PK only), reducing payload size by 90%+, then re-fetched with fresh data when the task executes
- Custom type support – Native handling of datetime, Decimal, UUID, sets without manual conversion
- Enterprise ACID guarantees – PostgreSQL/MySQL drivers with transactional dequeue
- Dead-letter queues – Automatic handling of permanently failed tasks
- Crash recovery – Visibility timeouts ensure tasks are never lost
- Graceful shutdown – SIGTERM/SIGINT handlers wait for in-flight tasks to complete
- Configurable retries – Per-task retry logic with custom
should_retry()hooks - Task timeouts – Prevent runaway tasks with per-task timeout configuration
- Real-time events – Redis Pub/Sub event streaming for task lifecycle monitoring
- Elegant, intuitive API – Clean, expressive syntax inspired by Laravel's queue system
- Type-safe – Full type hints with mypy/pyright support, Generic Task[T] for return types
- Zero configuration – Works with environment variables out of the box
- Multiple task styles – Function-based decorators or class-based tasks with lifecycle hooks
- Method chaining – Fluent API for task configuration:
.delay(60).on_queue("high").dispatch() - First-class FastAPI integration – Automatic lifecycle management and dependency injection
- Switch drivers instantly – Change one config line to swap between Redis, PostgreSQL, MySQL, RabbitMQ, or AWS SQS
- Same API everywhere – Write once, run on any driver without code changes
- Per-task driver override – Different tasks can use different drivers in the same application
- Production-ready options – From Redis to enterprise databases to managed cloud queues
-
✅ Async-first design with asyncio throughout the stack
-
✅ Multiple queue drivers: Redis, PostgreSQL, MySQL, RabbitMQ, AWS SQS
-
✅ High-performance msgpack serialization with binary support
-
✅ Automatic ORM model handling for SQLAlchemy, Django, Tortoise
-
✅ Type-safe with full type hints and Generic support
-
✅ Configurable retries with custom retry logic hooks
-
✅ Task timeouts to prevent runaway tasks
-
✅ Delayed task execution with precision timing
-
✅ Queue priority with multiple queues per worker
-
✅ Graceful shutdown with signal handlers
-
✅ ACID guarantees (PostgreSQL/MySQL drivers)
-
✅ Dead-letter queues for failed task inspection
-
✅ Visibility timeouts for crash recovery
-
✅ Connection pooling for optimal resource usage
-
✅ Transactional dequeue with
SELECT FOR UPDATE SKIP LOCKED -
✅ Task metadata tracking (attempts, timestamps, task IDs)
-
✅ Concurrent processing with configurable worker concurrency
-
✅ Real-time event streaming via Redis Pub/Sub
-
✅ FastAPI – Automatic lifecycle management, dependency injection
-
✅ SQLAlchemy – Async and sync model serialization
-
✅ Django ORM – Native async support (Django 3.1+)
-
✅ Tortoise ORM – Full async ORM integration
-
✅ asynctasq-monitor – Real-time monitoring dashboard (optional)
-
✅ Comprehensive CLI – Worker management and database migrations
-
✅ Function-based tasks with
@taskdecorator -
✅ Class-based tasks with lifecycle hooks (
handle,failed,should_retry) -
✅ Method chaining for fluent task configuration
-
✅ Environment variable configuration for 12-factor apps
Get started in 60 seconds:
# Install Async TasQ (Python 3.12+ required)
uv add asynctasq[redis]import asyncio
from asynctasq.config import set_global_config
from asynctasq.core.task import task
# 1. Configure (or use environment variables)
set_global_config(driver="redis", redis_url="redis://localhost:6379")
# 2. Define a task
@task
async def send_email(to: str, subject: str, body: str):
print(f"Sending email to {to}: {subject}")
await asyncio.sleep(1) # Simulate email sending
return f"Email sent to {to}"
# 3. Dispatch the task
async def main():
for i in range(10):
task_id = await send_email.dispatch(
to=f"user{i}@example.com", subject=f"Welcome {i}!", body="Welcome to our platform!"
)
print(f"Task dispatched: {task_id}")
if __name__ == "__main__":
asyncio.run(main())# Run the worker (in a separate terminal)
python -m asynctasq workerThat's it! Your first Async TasQ is ready. Now let's explore the powerful features.
- One-line setup:
just init— install deps and pre-commit hooks - Start services:
just services-up— Redis, PostgreSQL, MySQL, RabbitMQ, LocalStack (SQS) for local integration tests - Run tests:
just test(orpytest) — usejust test-unit/just test-integrationto scope - Run with coverage:
just test-covorpytest --cov=src/asynctasq --cov-report=html - Run the worker locally:
python -m asynctasq worker - Pre-commit hooks:
./setup-pre-commit.shorjust setup-hooks - Format / lint / typecheck:
just format,just lint,just typecheck
- CI runs on PRs and pushes to
mainand includes lint, type checks and tests across Python 3.12–3.14. - Pre-commit hooks enforce formatting and static checks locally before commits (see
./setup-pre-commit.sh). - Branch protection: enable required status checks (CI success, lint, unit/integration jobs) for
main. - Coverage badge: the repository updates
.github/coverage.svgautomatically via.github/workflows/coverage-badge.yml. - Run full CI locally:
just ci(runs format/lint/typecheck/tests like the workflow).
| Feature | Async TasQ | Celery |
|---|---|---|
| Async Support | ✅ Async-first, built with asyncio | ❌ No native asyncio support |
| Type Safety | ✅ Full type hints, Generic[T] | |
| Multi-Driver | ✅ 5 drivers (Redis/PostgreSQL/MySQL/RabbitMQ/SQS) | |
| ORM Integration | ✅ Auto-serialization (SQLAlchemy/Django/Tortoise) | ❌ Manual serialization |
| Serialization | ✅ msgpack (fast, binary) | |
| FastAPI Integration | ✅ First-class, lifespan management | |
| Dead-Letter Queue | ✅ Built-in (PG/MySQL) | |
| ACID Guarantees | ✅ PostgreSQL/MySQL drivers | ❌ Not available |
| Setup Complexity | ✅ Zero-config with env vars | |
| Learning Curve | ✅ Simple, intuitive API |
When to use Async TasQ:
- Modern async Python applications
- Need for type safety and IDE support
- Multiple driver options (dev → production)
- Automatic ORM model handling
- FastAPI applications
- Enterprise ACID requirements
When to use Celery:
- Mature ecosystem with many plugins
- Need for complex workflows (chains, chords)
- Large existing Celery codebase
| Feature | Async TasQ | Dramatiq |
|---|---|---|
| Async Support | ✅ Async-first | |
| Type Safety | ✅ Full type hints | ✅ Type hints (py.typed) |
| Multi-Driver | ✅ 5 drivers | |
| ORM Integration | ✅ Auto-serialization | ❌ Manual serialization |
| Dead-Letter Queue | ✅ Built-in | ✅ Built-in |
| FastAPI Integration | ✅ First-class | |
| Database Drivers | ✅ PostgreSQL/MySQL | ❌ Not available |
| Simplicity | ✅ Clean, intuitive API | ✅ Simple, well-designed |
When to use Async TasQ:
- Async applications (FastAPI, aiohttp)
- Type-safe codebase
- Database-backed queues (ACID)
- ORM model handling
When to use Dramatiq:
- Synchronous applications
- Need for mature, battle-tested library
- Complex middleware requirements
| Feature | Async TasQ | RQ |
|---|---|---|
| Async Support | ✅ Async-first | ❌ Sync only |
| Multi-Driver | ✅ 5 drivers | ❌ Redis only |
| Type Safety | ✅ Full type hints | ✅ Type hints added |
| Retries | ✅ Configurable with custom logic | ✅ Configurable retries |
| Dead-Letter Queue | ✅ Built-in | ❌ Not available |
| Database Drivers | ✅ PostgreSQL/MySQL | ❌ Not available |
| Simplicity | ✅ Intuitive, clean API | ✅ Very simple |
When to use Async TasQ:
- Async applications
- Multiple driver options
- Enterprise features (DLQ, ACID)
- Type safety
When to use RQ:
- Simple use cases
- Synchronous applications
- Redis-only infrastructure
| Feature | Async TasQ | Huey |
|---|---|---|
| Async Support | ✅ Async-first | |
| Multi-Driver | ✅ 5 drivers | |
| Type Safety | ✅ Full type hints | ❌ Limited |
| ORM Integration | ✅ Auto-serialization | ❌ Manual |
| Enterprise Features | ✅ ACID, DLQ, visibility timeout | |
| Simplicity | ✅ Clean, modern API | ✅ Simple |
When to use Async TasQ:
- Async-first applications
- Enterprise requirements
- Type-safe codebase
- ORM integration
When to use Huey:
- Lightweight use cases
- Simple task queues
- SQLite-backed queues
Async TasQ stands out with:
- True async-first design – Built with asyncio from the ground up
- msgpack serialization – Faster and more efficient than JSON
- Intelligent ORM handling – Automatic model serialization for 3 major ORMs
- Multi-driver flexibility – Seamlessly switch between 5 production-ready drivers (Redis, PostgreSQL, MySQL, RabbitMQ, SQS)
- Type safety – Full type hints with Generic[T] support
- Enterprise ACID guarantees – PostgreSQL/MySQL drivers with transactional dequeue
- Dead-letter queues – Built-in support for failed task inspection
- FastAPI integration – First-class support with lifecycle management
- Real-time event streaming – Redis Pub/Sub for live monitoring dashboards
- Optional monitoring UI – Beautiful dashboard via asynctasq-monitor
- Elegant, expressive API – Method chaining and intuitive task definitions
- Zero configuration – Works with environment variables out of the box
A beautiful real-time monitoring dashboard for Async TasQ:
- 📈 Live Dashboard – Real-time task metrics, queue depths, and worker status
- 📊 Task Analytics – Execution times, success/failure rates, retry patterns
- 🔍 Task Explorer – Browse, search, and inspect task details
- 👷 Worker Management – Monitor worker health and performance
- 🚨 Alerts – Get notified about failures and queue backlogs
# Install the monitoring package
uv add asynctasq-monitor
# Start the monitoring server
asynctasq-monitor webFor detailed documentation, see the following guides:
- Installation – Installation instructions for uv and pip
- Queue Drivers – Redis, PostgreSQL, MySQL, RabbitMQ, AWS SQS
- ORM Integrations – SQLAlchemy, Django, Tortoise ORM
- Framework Integrations – FastAPI integration
- Task Definitions – Function-based and class-based tasks
- Running Workers – CLI and programmatic workers
- Configuration – Environment variables, programmatic, CLI
- CLI Reference – Complete command reference
- Best Practices – Task design, queue organization, production deployment
For complete examples, see the following guides:
- Function-Based Tasks Examples – Complete examples guide
- Class-Based Tasks Examples – Complete examples guide
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
MIT License – see LICENSE file for details.
- Repository: github.com/adamrefaey/asynctasq
- Issues: github.com/adamrefaey/asynctasq/issues
- Discussions: github.com/adamrefaey/asynctasq/discussions
- SQLite driver support
- Oracle driver support
- Task batching support
- Task chaining and workflows (chains, chords, groups)
- Rate limiting
- Task priority within queues
- Scheduled/cron tasks
Built with ❤️ by Adam Refaey.