简体   繁体   English

带有一组任务的芹菜异常“TimeLimitExceeded”

[英]Celery's exception 'TimeLimitExceeded' with group of tasks

I have this celery's settings:我有这个芹菜的设置:

WORKER_MAX_TASKS_PER_CHILD = 1
TASK_TIME_LIMIT = 30

When i run group of tasks:当我运行一组任务时:

from celery import group, shared_task
from time import sleep

@shared_task
def do_something(arg):
    sleep(60)
    return arg*2

group([do_something.s(i) for i in range(3)]).apply_async()

I'm geting TimeLimitExceeded inside of group and then worker is killed by celery at once.我在组内得到TimeLimitExceeded ,然后工人立即被 celery 杀死。 How can i handle it?我该如何处理?

According to the documentation :根据文档

The soft time limit allows the task to catch an exception to clean up before it is killed: the hard timeout isn't catch-able and force terminates the task.软时间限制允许任务在被杀死之前捕获要清理的异常:硬超时是不可捕获的并且强制终止任务。

Answer will be simple: do not use hard-time limits for tasks if you want to catch exception.答案很简单:如果要捕获异常,请不要对任务使用硬时间限制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM