Skip to content

A task that raises Ignore shows as STARTED in event monitors #11093

Done

Description

@ChristianMurphy

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 main branch 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 report in the issue.
  • I have verified that the issue exists against the main branch of Celery.
  • I have included the contents of pip freeze in 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

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 SUCCESS

Expected 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

  1. Lushiyao5 commented on Nov 13, 2026

    @Lushiyao5
    Contributor

    Root cause confirmed by code reading on main (9c2f238):

    trace_task handles Ignore by setting state IGNORED, which is in IGNORE_STATES (celery/app/trace.py:115), so neither the success path nor the error path runs. The request object only sends terminal events from Request.on_success (task-succeeded, worker/request.py:631) and Request.on_failure (task-failed, worker/request.py:642) — task-retried only fires for RETRY. An IGNORED task therefore never gets any event after task-started, and anything built on events.State shows it as running forever.

    Possible directions, in increasing invasiveness — happy to implement whichever you prefer:

    1. New terminal event task-ignored sent from the IGNORED handling 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.
    2. Send task-succeeded for IGNORED with the stored result ( monitors need no changes, but the event would claim success for a task that was deliberately discarded).
    3. Document that Ignore tasks have no terminal event (status quo).

    Options 1 and 2 both need a unit decision on what the event payload should carry (the Ignore exception carries no result by default; stores_then_ignores in the repro shows the backend keeps the update_state value while the event stream has nothing).

  2. added this to the 5.7.x milestone on Nov 14, 2026
  3. ChristianMurphy commented on Nov 15, 2026

    @ChristianMurphy
    ContributorAuthor

    Thanks for confirming it, @Lushiyao5. I'd take option 1, the task-ignored event 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, as task-rejected adds only requeue.

  4. purnendu-rai commented on Nov 26, 2026

    @purnendu-rai
    Contributor

    Hi @ChristianMurphy — thanks for the clear report and for picking option 1 (task-ignored, minimal payload like task-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-ignored from the Ignore branch in Request.on_failure, and map it to the IGNORED state in celery.events.state) and would be glad to open the PR instead. Just let me know which you'd prefer. Thanks!

  5. auvipy commented on Nov 26, 2026

    @auvipy
    Member

    @purnendu-rai you can come with a PR to fix this

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions