How to check task status in Celery?

前端 未结 13 979
北荒
北荒 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:28

    I found helpful information in the

    Celery Project Workers Guide inspecting-workers

    For my case, I am checking to see if Celery is running.

    inspect_workers = task.app.control.inspect()
    if inspect_workers.registered() is None:
        state = 'FAILURE'
    else:
        state = str(task.state) 
    

    You can play with inspect to get your needs.

提交回复
热议问题