Celery

5.6.2 · active · verified Fri Mar 27

Distributed task queue for Python. Current version is 5.6.2 (Jan 2026). Requires Python >=3.9. A broker (Redis or RabbitMQ) is always required — there is no built-in broker. Old lowercase config settings (CELERY_TASK_SERIALIZER etc.) removed in Celery 5.0. SQS transport: pycurl→urllib3 in 5.5, then reverted in 5.6 — SQS users need pycurl reinstalled after 5.5→5.6 upgrade. Security fix: broker URL passwords were logged in plaintext before 5.6.

Warnings

Install

Imports

Quickstart

Requires Redis running. Start worker in separate terminal: celery -A tasks worker --loglevel=info

# tasks.py
from celery import Celery

app = Celery(
    'tasks',
    broker='redis://localhost:6379/0',
    backend='redis://localhost:6379/0'
)

app.conf.update(
    task_serializer='json',
    accept_content=['json'],
    result_serializer='json',
    timezone='UTC',
)

@app.task
def add(x, y):
    return x + y

@app.task(bind=True, max_retries=3)
def fetch_data(self, url):
    try:
        import requests
        return requests.get(url).json()
    except Exception as exc:
        raise self.retry(exc=exc, countdown=5)

# --- Run worker ---
# celery -A tasks worker --loglevel=info

# --- Call from client ---
# result = add.delay(4, 6)
# print(result.get(timeout=10))  # 10

view raw JSON →