A Django Tasks backend which uses RQ as its underlying queue.
python -m pip install django-tasks-rq
First, add django_tasks_rq to your INSTALLED_APPS:
INSTALLED_APPS = [
# ...
"django_tasks_rq",
]Finally, add it to your TASKS configuration:
TASKS = {
"default": {
"BACKEND": "django_tasks_rq.RQBackend",
"QUEUES": ["default"]
}
}The RQ-based backend acts as an interface between Django's tasks interface and RQ, allowing tasks to be defined and enqueued using django.tasks, but stored in Redis and executed using RQ's workers.
Any queues defined in QUEUES must also be defined in django-rq's RQ_QUEUES setting.
To use rq with django-tasks-rq, a custom Job class must be used. This can be passed to the worker using --job-class:
./manage.py rqworker --job-class django_tasks_rq.Jobrq has no native concept of priorities - instead relying on workers to define which queues they should pop tasks from in order. Therefore, task.priority has little effect on execution priority.
If a task has a priority of 100, it is enqueued at the top of the queue, and will be the next task executed by a worker. All other priorities will enqueue the task to the back of the queue. The queue value is not stored, and will always be 0.
See CONTRIBUTING.md for information on how to contribute.
Note: Prior to 0.12.0, this backend was included in django-tasks. Whilst the commit history was cleaned up, it's still quite messy. Don't look too closely.