Repository navigation
Description
A task that raises Ignore sends no event after task-started, so Flower and other event monitors show it as STARTED for as long as they keep it. That includes the pattern from the docs where a task stores its own state and then raises Ignore. It has been this way since 4.0.0 and 3.1.17, and is the same on 5.4.0 and 5.5.3. I'd add a task-ignored event, as Reject has task-rejected, and I can send that PR.
Main (9c2f238), a worker with -E |
State from events (app.events.State) |
State in the backend |
|---|---|---|
| Returns | SUCCESS | SUCCESS |
Raises Ignore |
STARTED | PENDING |
Calls update_state(state="SUCCESS"), then raises Ignore |
STARTED | SUCCESS |
Each row is 3 of 3 runs.
Cause
The tracer handles Ignore in celery/app/trace.py:572 and returns without a result, and the worker's request then sends no event for it. Up to 3.1.16 an ignored task got a task-failed event. #2365 removed that on purpose (3e7bbb6 on 3.1, e442df6 on master), and nothing took its place. Reject got its own event for the same reason (celery/worker/request.py:911).
A new event type means a monitor has to know it. The other choice is to send nothing and say so in the docs.
Checklist
Checklist
- I have verified that the issue exists against the
mainbranch of Celery. - This has already been asked to the discussions forum first.
- I have read the relevant section in the
contribution guide
on reporting bugs. - I have checked the issues list
for similar or identical bug reports. - I have checked the pull requests list
for existing proposed fixes. - I have checked the commit log
to find out if the bug was already fixed in the main branch. - I have included all related issues and possible duplicate issues in this issue (If there are none, check this box anyway).
- I have tried to reproduce the issue with pytest-celery and added the reproduction script below.
Mandatory Debugging Information
- I have included the output of
celery -A proj reportin the issue. - I have verified that the issue exists against the
mainbranch of Celery. - I have included the contents of
pip freezein the issue. - I have included all the versions of all the external dependencies required to reproduce this bug.
Optional Debugging Information
- I have tried reproducing the issue on more than one Python version and/or implementation.
- I have tried reproducing the issue on more than one message broker and/or result backend.
- I have tried reproducing the issue on more than one version of the message broker and/or result backend.
- I have tried reproducing the issue on more than one operating system.
- I have tried reproducing the issue on more than one workers pool.
- I have tried reproducing the issue with autoscaling, retries, ETA/Countdown & rate limits disabled.
- I have tried reproducing the issue after downgrading and/or upgrading Celery and its dependencies.
Related Issues and Possible Duplicates
Related Issues
- raise Ignore() incorrectly causes task FAILURE. #2365 removed the
task-failedevent forIgnore. - Reject exception doesn't cause the task to fail #4222 was the same gap for
Reject, fixed with thetask-rejectedevent.
Possible Duplicates
- None
Environment & Settings
Celery version: 5.7.0 (9c2f238)
celery report Output:
software -> celery:5.7.0 (collider) kombu:5.7.0 py:3.14.6
billiard:4.3.2 redis:8.1.0
platform -> system:Linux arch:64bit, ELF
kernel version:6.18.44-fc-v378 imp:CPython
loader -> celery.loaders.app.AppLoader
settings -> transport:redis results:redis://localhost:6379/1
broker_url: 'redis://:********@localhost:6379/0'
result_backend: 'redis://localhost:6379/1'
deprecated_settings: None
Steps to Reproduce
Required Dependencies
- Minimal Python Version: N/A or Unknown
- Minimal Celery Version: 5.4.0 tested (4.0.0 and 3.1.17 by the code)
- Minimal Kombu Version: N/A or Unknown
- Minimal Broker Version: Redis 7.4
- Minimal Result Backend Version: Redis 7.4
- Minimal OS and/or Kernel Version: N/A or Unknown
- Minimal Broker Client Version: N/A or Unknown
- Minimal Result Backend Client Version: N/A or Unknown
Python Packages
pip freeze Output:
billiard==4.3.2
celery @ main (9c2f238)
kombu @ main (445027e)
redis==8.1.0
Other Dependencies
Services
N/A
Minimally Reproducible Test Case
tasks.py, run.py and output
# tasks.py
from celery import Celery
from celery.exceptions import Ignore
app = Celery("tasks", broker="redis://localhost:6379/0",
backend="redis://localhost:6379/1")
@app.task
def returns():
return "done"
@app.task
def ignores():
raise Ignore()
@app.task(bind=True)
def stores_then_ignores(self):
self.update_state(state="SUCCESS", meta="done")
raise Ignore()# run.py
import threading
from tasks import app, ignores, returns, stores_then_ignores
state = app.events.State()
results = {}
def send():
for task in (returns, ignores, stores_then_ignores):
results[task.name] = task.delay()
with app.connection() as connection:
receiver = app.events.Receiver(connection, handlers={"*": state.event})
# Watch the events for 7 s, as a monitor would, and send the tasks
# once the receiver listens.
threading.Timer(1, send).start()
threading.Timer(7, setattr, (receiver, "should_stop", True)).start()
receiver.capture(wakeup=False)
for name, res in results.items():
print(f"{name}: monitor {state.tasks[res.id].state} | backend {res.state}")$ celery -A tasks worker -c 2 -E -l warning
$ python run.py
tasks.returns: monitor SUCCESS | backend SUCCESS
tasks.ignores: monitor STARTED | backend PENDING
tasks.stores_then_ignores: monitor STARTED | backend SUCCESSExpected Behavior
An event that tells a monitor the task has ended.
Actual Behavior
The last event is task-started. Anything built on events.State lists the task as running.
Activity
Lushiyao5 commentedon Nov 13, 2026
Root cause confirmed by code reading on main (9c2f238):
trace_taskhandlesIgnoreby setting stateIGNORED, which is inIGNORE_STATES(celery/app/trace.py:115), so neither the success path nor the error path runs. The request object only sends terminal events fromRequest.on_success(task-succeeded, worker/request.py:631) andRequest.on_failure(task-failed, worker/request.py:642) —task-retriedonly fires forRETRY. AnIGNOREDtask therefore never gets any event aftertask-started, and anything built onevents.Stateshows it as running forever.Possible directions, in increasing invasiveness — happy to implement whichever you prefer:
task-ignoredsent from theIGNOREDhandling path. Most honest semantically, but it is a new event type in the public monitoring protocol, so Flower and other consumers would need to learn it.task-succeededforIGNOREDwith the stored result ( monitors need no changes, but the event would claim success for a task that was deliberately discarded).Ignoretasks have no terminal event (status quo).Options 1 and 2 both need a unit decision on what the event payload should carry (the
Ignoreexception carries no result by default;stores_then_ignoresin the repro shows the backend keeps theupdate_statevalue while the event stream has nothing).ChristianMurphy commentedon Nov 15, 2026
Thanks for confirming it, @Lushiyao5. I'd take option 1, the
task-ignoredevent from the description, and I'll send that PR myself once my open PRs here are reviewed. On the payload: nothing beyond the task id, astask-rejectedadds onlyrequeue.purnendu-rai commentedon Nov 26, 2026
Hi @ChristianMurphy — thanks for the clear report and for picking option 1 (
task-ignored, minimal payload liketask-rejected).You mentioned on Nov 15 that you'd send the PR yourself once your open PRs are reviewed, so I don't want to step on that. If you're still planning to send it, no worries at all — please ignore this.
If it would help, I've worked out the change locally following your option 1 (emit
task-ignoredfrom theIgnorebranch inRequest.on_failure, and map it to theIGNOREDstate incelery.events.state) and would be glad to open the PR instead. Just let me know which you'd prefer. Thanks!auvipy commentedon Nov 26, 2026
@purnendu-rai you can come with a PR to fix this