How to inspect and cancel Celery tasks by task name

前端 未结 4 798
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-12 15:55

I\'m using Celery (3.0.15) with Redis as a broker.

Is there a straightforward way to query the number of tasks with a given name that exist in a Celery queue?

<
4条回答
  •  忘掉有多难
    2020-12-12 16:14

    You can do this in one request:

    app.control.revoke([
        uuid
        for uuid, _ in
        celery.events.state.State().tasks_by_type(task_name)
    ])
    

提交回复
热议问题