Overview
Celery 5.1, released on May 24, 2021, adds Django 3.2 support and improves task annotations for finer execution control.
Main Features
Django 3.2 support
Celery 5.1 is fully compatible with Django 3.2 LTS, ensuring stable integration for projects using the latest Django LTS release.
python
# celery.py (Django project)
import os
from celery import Celery
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
app = Celery('project')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()
@app.task(bind=True)
def debug_task(self):
print(f'Request: {self.request!r}')
Task annotations
Task annotations allow fine-grained configuration of task behavior: time limits, rate limits, and priorities, all from the configuration.
python
from celery import shared_task
@shared_task(
rate_limit='10/m',
time_limit=300,
max_retries=3,
default_retry_delay=60,
)
def send_email(recipient, subject, body):
"""Task with rate limit and timeout."""
# 10 executions max per minute, 5 min timeout
send_mail(recipient, subject, body)
# Async call
send_email.delay('user@example.com', 'Welcome', 'Hello!')
