在Celery中删除任务/周期性任务

9 投票
1 回答
6328 浏览
提问于 2025-04-15 21:06

我该怎么在celery中删除一个普通任务或定时任务呢?

1 个回答

16

你可以使用 revoke 来取消任务:详细信息请查看 文档

Control.revoke(task_id, destination=None, terminate=False, signal='SIGTERM', **kwargs)
    Tell all (or specific) workers to revoke a task by id.

    If a task is revoked, the workers will ignore the task and not execute it after all.

    Parameters: 
        task_id – Id of the task to revoke.
        terminate – Also terminate the process currently working on the task (if any).
        signal – Name of signal to send to process if terminate. Default is TERM.

撰写回答