Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Celery task state depends on CELERY_TASK_RESULT_EXPIRES

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)

like image 935
Clara Avatar asked Oct 11 '13 10:10

Clara


People also ask

Are celery tasks asynchronous?

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.

How do I get Celery status?

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 .

How does celery task queue work?

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.

What is Celery_acks_late?

CELERY_ACKS_LATE=True prevents acknowledging messages when they reach to a worker.


1 Answers

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.

like image 195
asksol Avatar answered Oct 14 '22 01:10

asksol