Skip to content

Conversation

@jaiganeshs21
Copy link
Contributor

@jaiganeshs21 jaiganeshs21 commented Jul 5, 2025

Summary

This PR updates the Task Handlers documentation to address the confusion described in issue #9787. The original documentation lacked clarity about handler execution context, timing, and order, leading to developer uncertainty about when and where these handlers run.

Issue Description

Issue #9787 highlighted that the handler execution documentation was unclear about:

  • Whether handlers run in the same process or externally
  • Execution order and timing relative to task completion
  • When result backend updates occur versus handler execution
  • Which handlers block task execution

Changes Made

  • Added Clear Execution Context
  • Created Visual Timeline Diagram
  • Reorganized Handler Methods
  • Added Practical Code Example

Resolves #9787

Current Docs

image

Updated Doc

image
image
image

@jaiganeshs21
Copy link
Contributor Author

@auvipy, Can you please review this?

@auvipy
Copy link
Member

auvipy commented Jul 5, 2025

yes

@auvipy auvipy requested review from auvipy and Copilot and removed request for Copilot July 5, 2025 14:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Clarify task handler execution context, timing, and ordering in the user guide, and provide a concrete example.

  • Add a synchronous execution timeline diagram showing handler order and blocking behavior
  • Reorganize and expand individual handler method docs with timing notes
  • Include a practical code example demonstrating all handlers in action
Comments suppressed due to low confidence (4)

docs/userguide/tasks.rst:1630

  • Indent the .. method:: directives consistently (e.g., prefix with two spaces) to match the existing before_start style and ensure correct Sphinx parsing.
.. method:: on_success(self, retval, task_id, args, kwargs)

docs/userguide/tasks.rst:1648

  • Add a note that the return value of on_retry is ignored, for consistency with the other handler docs (on_success and after_return).
.. method:: on_retry(self, exc, task_id, args, kwargs, einfo)

docs/userguide/tasks.rst:1666

  • Include a sentence stating that the return value of on_failure is ignored to mirror the pattern in on_success and after_return.
.. method:: on_failure(self, exc, task_id, args, kwargs, einfo)

docs/userguide/tasks.rst:1596

  • [nitpick] Consider updating ‘Outcome-specific handler’ to the plural ‘Outcome-specific handlers’ for clarity, since multiple handlers appear under this step.
    │  4. on_success() OR     ← Outcome-specific handler            │

@auvipy auvipy added this to the 5.6.0 milestone Jul 5, 2025
@auvipy auvipy merged commit bc24851 into celery:main Jul 7, 2025
4 of 5 checks passed
@auvipy
Copy link
Member

auvipy commented Jan 3, 2026

hey can you check this #10046 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

celery.Task Handlers execution order is unclear

2 participants