From what I have seen, the task state depends entirely on the value set for CELERY_TASK_RESULT_EXPIRES - if I check the task state within this interval after the task has finished executing, the state returned by:
AsyncResult(task_id).state
is correct. If not, the state will not be updated and will remain forever PENDING.
Can anyone explain me why does this happen? Is this a feature or a bug? Why is the task state depending on the result expiry time, even if I am ignoring results?
(Celery version: 3.0.23, result backend: AMQP)
Celery is a task queue/job queue based on asynchronous message passing. It can be used as a background task processor for your application in which you dump your tasks to execute in the background or at any given moment. It can be configured to execute your tasks synchronously or asynchronously.
By default, Celery does not record a "running" state. When task_track_started is False , which is the default, the state show is PENDING even though the task has started. If you set task_track_started to True , then the state will be STARTED .
Celery is an open-source, simple, flexible, distributed system to process vast amounts of messages while providing operations with the tools required to maintain such a system. It's a task queue with a focus on real-time processing, while also supporting task scheduling.
CELERY_ACKS_LATE=True prevents acknowledging messages when they reach to a worker.
State and result is the same. The result backend was initially used to store return values then it was extended to store arbitrary states. The term result was not sufficient anymore as it implies that the task has completed. ignore_result
should be ignore_state
, but we haven't had the chance to rename that yet. I have a plan to clean up the terminology used here, but it will take some time to be backward compatible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With