You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Reject exception doesn't cause the task to fail #2944
I have a simple worker that rejects the task in case of an exception (such as ZeroDivisionError):
@app.task(bind=True, max_retries=0)
def invert(*args, **kwargs):
try:
x = float(kwargs['x'])
logging.info("x=%f", x)
result = 1.0 / float(x)
logging.info("Result=%f", result)
except Exception as e:
raise Reject(e) from e
By running this worker and monitoring the outcome of the tasks using Celery Flower, I noticed that with Celery 3.1.16, the Reject exception causes the task to fail (FAILURE state), but with Celery 3.1.19 (actually 3.1.17+), the same exception does not change the task's state (it is kept in STARTED state).
FAILURE is a final state, and rejecting a task means to requeue the task, or to let it be moved to a dead letter queue (with the possibility of ignoring the message completely), so the task must still be in a pending state.
I added a new task-rejected event for 4.0, so that it can at least be visible in the monitor.
Activity
mhnagaoka commentedon Dec 1, 2015
With Celery 3.1.16, the rejected task ends in
FAILUREstate.With Celery 3.1.19, the rejected task is kept in
STARTEDstate.ask commentedon Dec 11, 2015
FAILURE is a final state, and rejecting a task means to requeue the task, or to let it be moved to a dead letter queue (with the possibility of ignoring the message completely), so the task must still be in a pending state.
I added a new task-rejected event for 4.0, so that it can at least be visible in the monitor.
ask commentedon Dec 11, 2015
Closed by 8454428