Repository navigation
Mark rejected tasks as failed when not requeued - #10369
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10369 +/- ##
=======================================
Coverage 88.35% 88.35%
=======================================
Files 153 153
Lines 19770 19775 +5
Branches 2292 2294 +2
=======================================
+ Hits 17467 17472 +5
Misses 2004 2004
Partials 299 299
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
auvipy
self-requested a review
June 21, 2026 08:20
hmnfalahi
marked this pull request as draft
June 21, 2026 18:50
hmnfalahi
force-pushed
the
fix-reject-mark-failure
branch
from
June 21, 2026 21:17
ccd47af to
37f70de
Compare
hmnfalahi
marked this pull request as ready for review
June 21, 2026 21:19
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses Celery issue #4222 by ensuring tasks that raise Reject(requeue=False) are recorded as a terminal failure (instead of being left in PENDING/STARTED), and by documenting and testing the updated behavior.
Changes:
- Update
Request.on_failure()to store aFAILUREresult, emittask_failure, and send atask-failedevent forReject(requeue=False). - Add unit tests covering both non-requeued and requeued
Rejectpaths (including the already-acked case). - Document the new semantics of
Reject(requeue=False)vsReject(requeue=True)in the user guide.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
celery/worker/request.py |
Records a terminal failure + emits failure signal/event when Reject(requeue=False) is raised. |
t/unit/worker/test_request.py |
Adds regression tests for Reject handling (non-requeue and requeue paths). |
docs/userguide/tasks.rst |
Documents how Celery treats Reject with and without requeue. |
hmnfalahi
force-pushed
the
fix-reject-mark-failure
branch
2 times, most recently
from
June 25, 2026 19:35
d9c7bad to
6b7711a
Compare
hmnfalahi
force-pushed
the
fix-reject-mark-failure
branch
from
June 25, 2026 21:46
6b7711a to
44cdc99
Compare
auvipy
reviewed
Jun 27, 2026
auvipy
approved these changes
Jun 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #4222.
When a task raises
Reject(requeue=False), the message is rejected and will not be executed again. Previously the result backend was not updated, which could leave the task inPENDINGorSTARTED.This change records a terminal failure result for non-requeued rejects and emits the
task_failuresignal. Requeued rejects keep the existing behavior.Added unit coverage for both non-requeued and requeued
Rejectpaths.