Detect whether Celery is Available/Running

后端 未结 7 560
遥遥无期
遥遥无期 2020-12-04 12:09

I\'m using Celery to manage asynchronous tasks. Occasionally, however, the celery process goes down which causes none of the tasks to get executed. I would like to be able t

7条回答
  •  天涯浪人
    2020-12-04 12:33

    The below script is worked for me.

        #Import the celery app from project
        from application_package import app as celery_app
        def get_celery_worker_status():
            insp = celery_app.control.inspect()
            nodes = insp.stats()
            if not nodes:
                raise Exception("celery is not running.")
            logger.error("celery workers are: {}".format(nodes))
            return nodes
    

提交回复
热议问题