Skip to main content

A multiprocessing distributed task queue for Django

PyPI version Quality Gate Status Coverage

Django Q2 is a fork of Django Q. Big thanks to Ilan Steemers for starting this project. Unfortunately, development has stalled since June 2021. Django Q2 is the new updated version of Django Q, with dependencies updates, docs updates and several bug fixes. Original repository: https://github.com/Koed00/django-q

Capabilities

Everything the library provides, at a glance. How you get it points at the API call or Q_CLUSTER setting that activates each capability.

Legend: ✅ supported · ⚙️ built-in / on by default · ⚠️ supported, with a caveat · 🧩 optional (extra setting or dependency)

Dispatch & execution

Capability Status How you get it
Fire-and-forget async tasks (callable or "module.func" path) ✅ async_task("app.tasks.fn", *args, **kwargs)
Synchronous/inline run for tests & debugging ⚙️ async_task(..., sync=True) or Q_CLUSTER={"sync": True}
Per-task & global timeouts ✅ async_task(..., timeout=30) / Q_CLUSTER={"timeout": 60}
Multiprocessing worker pool ⚙️ python manage.py qcluster (workers default to CPU count)
Worker recycling & memory cap (RSS) ✅ Q_CLUSTER={"recycle": 500, "max_rss": 100000}
CPU-affinity pinning 🧩 Q_CLUSTER={"cpu_affinity": 1} (needs psutil)

Results & state

Capability Status How you get it
Result retrieval / blocking wait ✅ result(id, wait=2000) / fetch(id)
Result hooks (post-run callback) ✅ async_task(..., hook="app.hooks.cb")
Success/Failure persisted to the database ⚙️ Task / Success / Failure models in the Admin
Cache result backend (skip the database) 🧩 cached=True / Q_CLUSTER={"cached": 60}
Save-limit trimming (per group/name/func) ✅ Q_CLUSTER={"save_limit": 250, "save_limit_per": "func"}

Composition

Capability Status How you get it
Task groups + group results/counts ✅ async_task(..., group="g") then result_group("g")
Sequential chains ✅ Chain().append(...).run() / async_chain([...])
Iterable fan-out ✅ Iter() / async_iter(fn, [args, ...])

Scheduling

Capability Status How you get it
Scheduled & repeating tasks (minutes → yearly) ✅ schedule(..., schedule_type=Schedule.DAILY, repeats=-1)
Cron expressions 🧩 schedule_type=Schedule.CRON, cron="0 22 * * 1-5" (needs croniter)
ONCE auto-cleanup & repeat countdown ⚙️ automatic once repeats reaches 0
Catch-up vs. skip missed runs ⚙️ Q_CLUSTER={"catch_up": False}
Manage schedules via Admin or ORM ✅ Schedule is a regular Django model

Reliability & security

Capability Status How you get it
Retry of un-acked tasks ⚠️ Q_CLUSTER={"retry": 90, "timeout": 60} — retry must exceed timeout
Max attempts + attempt tracking ✅ Q_CLUSTER={"max_attempts": 3}; observers read task["attempt"]
Acknowledge failures (drop from the queue) ✅ ack_failure=True / Q_CLUSTER={"ack_failures": True}
Signed (HMAC) task packages ⚙️ automatic, uses Django's SECRET_KEY
Exit instead of hanging after an abnormal process death 🧩 Q_CLUSTER={"exit_on_abnormal_death": True} (needs a supervisor that restarts the cluster)
Compressed payloads 🧩 Q_CLUSTER={"compress": True}

Brokers

Capability Status How you get it
Redis · IronMQ · Amazon SQS · MongoDB · Django ORM ✅ Q_CLUSTER={"redis": {...}} (or orm / sqs / mongo / iron_mq)
Custom broker class ✅ Q_CLUSTER={"broker_class": "path.to.Broker"}
Multiple clusters / queues on one backend ✅ async_task(..., cluster="x") / ALT_CLUSTERS

Operations & observability

Capability Status How you get it
Management CLI: qcluster / qmonitor / qmemory / qinfo ✅ python manage.py qmonitor
Django Admin integration ⚙️ tasks & schedules visible in the Admin
Pluggable error reporters (Sentry / Rollbar) 🧩 Q_CLUSTER={"error_reporter": {...}} + reporter plugin
Lifecycle signals (post_spawn, pre_enqueue, pre_execute, post_execute, post_execute_in_worker) ✅ connect Django signals from django_q.signals
Chain-progress signals (pre_chain_progress / post_chain_progress) ✅ carry cross-process context (e.g. OpenTelemetry) across chain links
OpenTelemetry-style instrumentation 🧩 built on the signals above — see opentelemetry-instrumentation-django-q2-full-of-juice
Localized UI (English / German / Turkish / French) ✅ automatic via Django i18n

OpenTelemetry

Need distributed tracing that survives the queue boundary? The companion package opentelemetry-instrumentation-django-q2-full-of-juice turns the lifecycle signals this fork ships into real OpenTelemetry spans. An HTTP request → task A → task B → task C graph then shows up as one continuous distributed trace.

It propagates trace context (and W3C Baggage) producer → broker → worker — the carrier rides inside the signed task payload — and emits producer/consumer spans, duration histograms, and messaging semantic-convention attributes. The chain-progress signals (pre_chain_progress / post_chain_progress) are unique to this fork: they let every link of an async_chain land on the same trace.

Install it alongside django-q2:

pip install opentelemetry-instrumentation-django-q2-full-of-juice

Turn it on once, before any worker forks (your AppConfig.ready() is the canonical spot):

from opentelemetry_instrumentation_django_q2 import DjangoQ2Instrumentor

DjangoQ2Instrumentor().instrument()

Or activate it with zero code via the OpenTelemetry bootstrap CLI:

opentelemetry-instrument python manage.py qcluster

See the package documentation for the full capability matrix, bring-your-own-provider setup, and caveats.

Changes compared to the original Django-Q

  • Dropped support for Disque (hasn't been updated in a long time)
  • Dropped Redis, Arrow and Blessed dependencies
  • Updated all current dependencies
  • Added tests for Django 4.x and 5.x
  • Added Turkish language
  • Improved admin area
  • Fixed a lot of issues

See the changelog for all changes.

Requirements

Tested with:

  • Python 3.12 to 3.13.
  • Django 5.0 to 6.0.

Brokers

Installation

  • Install the latest version with pip:

    pip install django-q2-full-of-juice
    
  • Add django_q to your INSTALLED_APPS in your project's settings.py:

    INSTALLED_APPS = (
        # other apps
        'django_q',
    )
    
  • Run Django migrations to create the database tables:

    python manage.py migrate
    
  • Choose a message broker, configure and install the appropriate client library.

Read the full documentation at https://tinuvi.github.io/django-q2-full-of-juice/

Configuration

All configuration settings are optional. e.g:

# settings.py example
Q_CLUSTER = {
    'name': 'myproject',
    'workers': 8,
    'recycle': 500,
    'timeout': 60,
    'compress': True,
    'cpu_affinity': 1,
    'save_limit': 250,
    'queue_limit': 500,
    'label': 'Django Q',
    'redis': {
        'host': '127.0.0.1',
        'port': 6379,
        'db': 0,
    }
}

For full configuration options, see the configuration documentation.

Management Commands

For the management commands to work, you will need to install Blessed: https://github.com/jquast/blessed

Start a cluster with:

python manage.py qcluster

Monitor your clusters with:

python manage.py qmonitor

Monitor your clusters' memory usage with:

python manage.py qmemory

Check overall statistics with:

python manage.py qinfo

Creating Tasks

Use async_task from your code to quickly offload tasks:

from django_q.tasks import async_task, result

# create the task
async_task('math.copysign', 2, -2)

# or with a reference
import math.copysign

task_id = async_task(copysign, 2, -2)

# get the result
task_result = result(task_id)

# result returns None if the task has not been executed yet
# you can wait for it
task_result = result(task_id, 200)

# but in most cases you will want to use a hook:

async_task('math.modf', 2.5, hook='hooks.print_result')

# hooks.py
def print_result(task):
    print(task.result)

For more info see Tasks

Schedule

Schedules are regular Django models. You can manage them through the Admin page or directly from your code:

# Use the schedule function
from django_q.tasks import schedule

schedule('math.copysign',
         2, -2,
         hook='hooks.print_result',
         schedule_type=Schedule.DAILY)

# Or create the object directly
from django_q.models import Schedule

Schedule.objects.create(func='math.copysign',
                        hook='hooks.print_result',
                        args='2,-2',
                        schedule_type=Schedule.DAILY
                        )

# Run a task every 5 minutes, starting at 6 today
# for 2 hours
from datetime import datetime

schedule('math.hypot',
         3, 4,
         schedule_type=Schedule.MINUTES,
         minutes=5,
         repeats=24,
         next_run=datetime.utcnow().replace(hour=18, minute=0))

# Use a cron expression
schedule('math.hypot',
         3, 4,
         schedule_type=Schedule.CRON,
         cron='0 22 * * 1-5')

For more info check the Schedules documentation.

Development

There is an example project that you can use to develop with. Docker (compose) is being used to set everything up. Please note that you will have to restart the django-q container when changes have been made to tasks or django-q. You can start the example project with:

make dev

Create a superuser with:

make createsuperuser

Testing

Running tests is easy with docker compose, it will also start the necessary databases. Just run:

make test

Locale

Currently available in English, German, Turkish, and French. Translation pull requests are always welcome.

Acknowledgements

Metadata

Release files for django-q2-full-of-juice 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-q2-full-of-juice 0.2.0
File Size Uploaded Provenance Actions
django_q2_full_of_juice-0.2.0.tar.gz 85.6 kB Without provenance Details for django_q2_full_of_juice-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-q2-full-of-juice 0.2.0
File Interpreter ABI Platform Actions
django_q2_full_of_juice-0.2.0-py3-none-any.whl Python 3 none any Details for django_q2_full_of_juice-0.2.0-py3-none-any.whl

Total release size: 182.1 kB

Release files / django_q2_full_of_juice-0.2.0.tar.gz

Download URL django_q2_full_of_juice-0.2.0.tar.gz
Size 85.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f9c555174193be13c99b48cce32ffb826600cc3069c1480ec5b9899c13e7b6f5
BLAKE2b-256 checksum
How to use checksums
78f506d5ce4e96483eb960d8fa50f00885fc869d09a544e95114194317d65f39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.14.10 Linux/7.0.0-1020-azure

Release files / django_q2_full_of_juice-0.2.0-py3-none-any.whl

Download URL django_q2_full_of_juice-0.2.0-py3-none-any.whl
Size 96.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e278ead410651d9be0bffdea8bbbcd153f43b03ac1d67d50edcf615bd526e9ec
BLAKE2b-256 checksum
How to use checksums
2c79be9ab59085a1ed8c024e39847fa826978e4701e2aed918b757a333f17933
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.14.10 Linux/7.0.0-1020-azure

Security for django-q2-full-of-juice 0.2.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page