How to check task status in Celery?

前端 未结 13 966
北荒
北荒 2020-11-28 02:44

How does one check whether a task is running in celery (specifically, I\'m using celery-django)?

I\'ve read the documentation, and I\'ve googled, but I can\'t see a

13条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-28 03:41

    Return the task_id (which is given from .delay()) and ask the celery instance afterwards about the state:

    x = method.delay(1,2)
    print x.task_id
    

    When asking, get a new AsyncResult using this task_id:

    from celery.result import AsyncResult
    res = AsyncResult("your-task-id")
    res.ready()
    

提交回复
热议问题