duanqiao1947 2014-10-29 09:40
浏览 726

如何在Celery中完成失败的任务?

I am using celery to process some tasks. I can see how many are active or scheduled etc, but I am not able to find any way to see the tasks that have failed. Flower does show me the status but only if it was running when the task was started and failed. Is there any command to get all the tasks that have failed (STATUS: FAILURE) ?

I do have the task id when the task was created. But there are millions of them. So I can't check one by one even if there is a way to check it by task ID. But if there is such a command, please let me know.

  • 写回答

2条回答 默认 最新

  • douzhang7184 2014-10-29 12:25
    关注

    task id has state and status properties. So you can get the status of tasks by id.

    my_task_id = my_task.delay(foo)
    my_task_id.state
    my_task_id.status
    

    gives the status whether it is PENDING, STARTED, RETRY, FAILURE or SUCCESS.

    afaik, celery show only active, scheduled, reserved, revoked but id doesn't show failed tasks.

    Since you have all task id's, you can just loop over their status.

    for task_id in task_id_list:
        if task_id.state == 'FAILURE'
            print(task_id)
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考