AsyncResult(task_id) returns “PENDING” state even after the task started

十年热恋 提交于 2019-12-05 06:14:08

It's probably related to CELERY_TRACK_STARTED setting. Quoting the docs:

CELERY_TRACK_STARTED

If True the task will report its status as “started” when the task is executed by a worker. The default value is False as the normal behaviour is to not report that level of granularity. Tasks are either pending, finished, or waiting to be retried. Having a “started” state can be useful for when there are long running tasks and there is a need to report which task is currently running.

Maybe you have CELERY_TRACK_STARTED = True in your development settings, but not in production ?

For Celery 4.1.0 and Django 1.11.7 this is what you need in the config.py file:

Correct:

task_track_started = True

Also Correct:

CELERY_TASK_TRACK_STARTED = True

WRONG!:

CELERY_TRACK_STARTED = True

Just took me 2 hours to figure out. Hope this serves somebody in the near future

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!