Skip to content

feat(task): decouple acks_on_failure and acks_on_timeout - #10150

Merged
auvipy merged 4 commits into
celery:mainfrom
abdullahmujahidali:feat/decouple-acks-on-failure-timeout-10128
Feb 28, 2026
Merged

auvipy merged 4 commits into
celery:mainfrom
abdullahmujahidali:feat/decouple-acks-on-failure-timeout-10128

Conversation

@abdullahmujahidali

Copy link
Copy Markdown
Contributor

Description

Fixes #10128

Currently acks_on_failure_or_timeout is a single boolean controlling ack behavior for both failure and timeout. There's no way to ack on failure (to send messages to a DLQ) but requeue on timeout.

This splits it into two independent settings: task_acks_on_failure and task_acks_on_timeout. Both default to None, falling back to the existing acks_on_failure_or_timeout so current behavior is preserved. The old setting is marked deprecated.

On the runtime side, on_timeout() now checks acks_on_timeout and on_failure() checks acks_on_failure for regular exceptions or acks_on_timeout for TimeLimitExceeded.

@abdullahmujahidali abdullahmujahidali changed the title feat(task): decouple acks_on_failure and acks_on_timeout (#10128) feat(task): decouple acks_on_failure and acks_on_timeout Feb 27, 2026
@auvipy
auvipy requested review from auvipy and Copilot and removed request for Copilot February 28, 2026 10:08
@auvipy auvipy added this to the 5.7.0 milestone Feb 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces independent acknowledgment controls for task failures vs. timeouts, enabling workflows like “ack on failure for DLQ, but requeue on timeout” while preserving existing behavior via fallback to task_acks_on_failure_or_timeout and deprecating the old combined setting.

Changes:

  • Add new config/task flags task_acks_on_failure and task_acks_on_timeout (default None, fallback to the legacy combined flag).
  • Update worker request handling so on_timeout() uses acks_on_timeout and on_failure() uses acks_on_failure (or acks_on_timeout for TimeLimitExceeded).
  • Extend unit tests and configuration docs to cover the new flags and deprecation.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
celery/worker/request.py Switch timeout/failure ack/reject decisions to the new per-case flags.
celery/app/task.py Add task attributes and binding-time fallback logic for the new flags.
celery/app/defaults.py Add new configuration options and deprecation metadata for the legacy flag.
docs/userguide/configuration.rst Document the new settings and mark the old one deprecated.
t/unit/worker/test_request.py Add/adjust tests to validate independent failure vs. timeout behavior.

Comment thread celery/app/defaults.py Resolved
Comment thread t/unit/worker/test_request.py Resolved
@codecov

codecov Bot commented Feb 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.55%. Comparing base (63f70cf) to head (e8decad).
⚠️ Report is 98 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10150   +/-   ##
=======================================
  Coverage   87.54%   87.55%           
=======================================
  Files         153      153           
  Lines       19413    19422    +9     
  Branches     2231     2234    +3     
=======================================
+ Hits        16996    17005    +9     
  Misses       2121     2121           
  Partials      296      296           
Flag Coverage Δ
unittests 87.53% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@auvipy
auvipy merged commit 40c2349 into celery:main Feb 28, 2026
322 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Acknowledgment of task's failure and timeout should be decoupled

3 participants