← ClaudeAtlas

django-celerylisted

Background task / message-queue patterns with Celery + Redis or RabbitMQ — broker config, idempotent tasks, retries with backoff, dead-letter handling, canvas (chain/group/chord), beat scheduling, monitoring, and testing. Use when adding background jobs, async processing, scheduled tasks, or a task queue to a Python service.
SilantevBitcoin/Base-system-Claude · ★ 1 · AI & Automation · score 74
Install: claude install-skill SilantevBitcoin/Base-system-Claude
# Celery Task-Queue & Async Processing Patterns Production-grade patterns for background task processing in Python (Django shown) using Celery with Redis or RabbitMQ as the broker. The task-design patterns below — idempotency, retry/backoff, acks-late, dead-letter — are broker- and framework-agnostic; the configuration API is Celery-specific. ## When to Activate - Adding background jobs or async processing to a service - Implementing periodic/scheduled tasks - Offloading slow operations (email, PDF generation, API calls) from the request cycle - Setting up Celery Beat for cron-like scheduling - Debugging task failures, retries, or queue backlogs - Writing tests for queue consumers ## Project Setup ### Installation ```bash pip install celery[redis] django-celery-results django-celery-beat ``` ### `celery.py` — App Entrypoint ```python # config/celery.py import os from celery import Celery os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.development') app = Celery('myproject') app.config_from_object('django.conf:settings', namespace='CELERY') app.autodiscover_tasks() # Discovers tasks.py in each INSTALLED_APP @app.task(bind=True, ignore_result=True) def debug_task(self): print(f'Request: {self.request!r}') ``` ```python # config/__init__.py from .celery import app as celery_app __all__ = ('celery_app',) ``` ### Broker & Worker Settings ```python # config/settings/base.py # Broker (Redis or RabbitMQ) CELERY_BROKER_URL = env('CELERY_BROKER_URL