Skip to content

Instantly share code, notes, and snippets.

@tsundokul
Created September 4, 2025 16:56
Show Gist options
  • Save tsundokul/f910e6b1ce4a3e3c7d511e084de835ca to your computer and use it in GitHub Desktop.
Save tsundokul/f910e6b1ce4a3e3c7d511e084de835ca to your computer and use it in GitHub Desktop.
Celery task lifetime cycle

see https://docs.celeryq.dev/en/stable/userguide/signals.html

[worker_init] --> Worker instance starts

[before_task_publish] --> Before task message sent to broker
    |
    v
[task_sent] / [after_task_publish] --> Task message dispatched to broker

[task_received] --> Worker receives the task message
    |
    v
[task_started] --> Worker starts executing the task
    |
    +------------------------------+
    |                              |
    v                              v
[task_succeeded]           [task_failed]
    |                              |
    |                              v
    |                         [task_retried]  (optionally if retry)
    |                              |
    +------------------------------+
    |
    v
[task_revoked] (can happen anytime before or during execution)

[worker_shutdown] --> Worker instance shuts down
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment