How to check task status in Celery?

前端 未结 13 975
北荒
北荒 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

    • First,in your celery APP:

    vi my_celery_apps/app1.py

    app = Celery(worker_name)
    
    • and next, change to the task file,import app from your celery app module.

    vi tasks/task1.py

    from my_celery_apps.app1 import app
    
    app.AsyncResult(taskid)
    
    try:
       if task.state.lower() != "success":
            return
    except:
        """ do something """
    
    
    

提交回复
热议问题