Django tasks Repid backend
Project description
django-tasks-repid
A django-tasks backend powered by repid.
Requirements
- Python 3.12+
- Django 6.0+
- django-tasks 0.12+
- repid 1.6+
Installation
pip install django-tasks-repid
Configuration
Add the backend to your TASKS setting:
TASKS = {
"default": {
"BACKEND": "django_tasks_repid.backend.RepidBackend",
"QUEUES": ["default"],
"OPTIONS": {
"BROKER": "redis://localhost:6379",
"RESULT_BACKEND": "redis://localhost:6379",
},
}
}
Options
| Option | Description | Default |
|---|---|---|
BROKER |
Message broker DSN. Supports amqp://, redis://, valkey://. |
In-memory (development only) |
RESULT_BACKEND |
Redis DSN for storing task results. Required for get_result(). |
None (results unavailable) |
Supported brokers
| Scheme | Backend |
|---|---|
amqp:// |
RabbitMQ |
redis:// |
Redis |
valkey:// |
Valkey (protocol-compatible with Redis) |
| (none) | In-memory (single-process, non-persistent — development only) |
Defining tasks
from django_tasks import task
@task()
def send_welcome_email(user_id: int) -> None:
...
@task()
async def generate_report(report_id: int) -> dict:
...
Enqueueing tasks
# Sync
result = send_welcome_email.enqueue(user_id=42)
# Async
result = await send_welcome_email.aenqueue(user_id=42)
# Deferred
from datetime import datetime, timedelta, timezone
result = send_welcome_email.using(
run_after=datetime.now(tz=timezone.utc) + timedelta(hours=1)
).enqueue(user_id=42)
Retrieving results
get_result() and aget_result() require RESULT_BACKEND to be configured.
from django_tasks import default_task_backend
result = send_welcome_email.enqueue(user_id=42)
# Later — fetch updated status
result = default_task_backend.get_result(result.id)
if result.is_finished:
print(result.return_value)
Running a worker
Use repid's worker to consume and execute tasks:
# worker.py
import django
django.setup()
import asyncio
from repid import Connection, Queue, Repid, Router
from repid.connections import RedisMessageBroker
from myapp.tasks import send_welcome_email
router = Router()
router.include_func(send_welcome_email.func)
async def main():
async with Repid(Connection(RedisMessageBroker("redis://localhost:6379"))).magic():
await Queue("default").declare()
worker = router.create_worker(Queue("default"))
await worker.run()
asyncio.run(main())
Development / testing
The in-memory broker (no BROKER configured) is useful for tests:
# settings.py
TASKS = {
"default": {
"BACKEND": "django_tasks_repid.backend.RepidBackend",
"OPTIONS": {},
}
}
Run the test suite:
uv run pytest
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 django_tasks_repid-0.1.2.tar.gz.
File metadata
- Download URL: django_tasks_repid-0.1.2.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
705f36771520c4720e89ce0367b3d7a9c1b88f4388bb6e92bcda9fa3540198f7
|
|
| MD5 |
f9b08426344dd26c8f99a25d9d2111a9
|
|
| BLAKE2b-256 |
eb60d2d60be168e80bbcfb14020892f393cc9eff3328c6866e99eefaeb7959fc
|
File details
Details for the file django_tasks_repid-0.1.2-py3-none-any.whl.
File metadata
- Download URL: django_tasks_repid-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7f465b8e42aaecc680b2f2d59edfeb12e4732b01e9358109d00520f7d5a7d9f
|
|
| MD5 |
1e64117f1b571e01d04ed1bc9b73891d
|
|
| BLAKE2b-256 |
7f64f6112079b17026204731fe7ad859492cc95cf29ef0fe9478a4708c6bb959
|