Process background tasks with Celery.
Handle long-running tasks asynchronously.
Setup
# tasks.py
from celery import Celery
app = Celery(‘tasks’, broker=’redis://localhost’)
@app.task
def send_email(to, subject):
# Send email logic
return “sent”
Calling Tasks
result = send_email.delay(“user@example.com”, “Hello”)
print(result.get(timeout=10))
Docker Compose
worker:
command: celery -A tasks worker
Conclusion
Celery enables scalable background processing!