Overview
Celery 5.2, released on January 2, 2022, adds Python 3.10 support and improves canvas primitives for task orchestration.
Main Features
Python 3.10 support
Celery 5.2 is fully compatible with Python 3.10, fixing issues related to changes in the collections module and new language features.
python
from celery import Celery
app = Celery('demo', broker='redis://localhost:6379/0')
@app.task
def add(x: int, y: int) -> int:
return x + y
# Asynchronous call
result = add.delay(4, 6)
print(result.get(timeout=10)) # 10
Canvas improvements
Canvas primitives (chain, group, chord) are more robust and better handle partial errors in task groups.
python
from celery import chain, group, chord
# Task chain
workflow = chain(
add.s(2, 3),
add.s(10),
) # (2+3) then result+10 = 15
# Parallel group with callback
workflow = chord(
group(add.s(i, i) for i in range(5)),
add.s(0), # sum of results
)
