Home / Market / django celery

django celery

Django + Celery async task patterns — configuration, task design, beat scheduling, retries, canvas workflows, monitoring, and testing. Use when adding background jobs, scheduled tasks, or async processing to a Django app.

skill★ 3173200 dlgithubMITInstall in CosmosUpstream Source

Documentation & Preview

--- name: django-celery description: DjangoおよびCeleryを使用した非同期タスク処理。タスクキューイング、ワーカー管理、エラー処理、スケジューリング。Redis/RabbitMQ ブローカー統合。 origin: ECC

---

Django + Celery 非同期タスク

Django でのバックグラウンドジョブと非同期処理。

使用時期

セットアップ

1. Celery インストール

pip install celery redis

2. タスク定義

from celery import shared_task

@shared_task
def send_email(recipient):
    # メール送信ロジック
    pass

3. ワーカー起動

celery -A myapp worker -l info

タスク

非同期実行

send_email.delay(recipient)  # すぐにキューに追加、非同期実行

スケジューリング

from celery.schedules import crontab

app.conf.beat_schedule = {
    'send-report-daily': {
        'task': 'app.tasks.send_report',
        'schedule': crontab(hour=9, minute=0),
    },
}

エラーハンドリング

詳細については、ドキュメントを参照してください。