代码之家  ›  专栏  ›  技术社区  ›  pomo_mondreganto

芹菜的@shared\u任务没有软时间限制

  •  0
  • pomo_mondreganto  · 技术社区  · 7 年前

    下面是一些简单的代码:

    @shared_task(time_limit=10, soft_time_limit=5)
    def check_action():
        try:
            __import__("time").sleep(100)
        except celery.exceptions.SoftTimeLimitExceeded as e:
            print("Here", e, type(e))
        except BaseException as e:
            print("There", e, type(e))
    

    shared_task 具有 time_limit soft_time_limit Here SoftTimeLimitExceeded 异常信息),然后 There 打印时出现一些硬超时异常。

    需要软时间限制

    celery_1               | [2019-05-31 21:36:36,709: WARNING/MainProcess] There
    celery_1               | [2019-05-31 21:36:36,710: WARNING/MainProcess] 10 seconds
    celery_1               | [2019-05-31 21:36:36,710: WARNING/MainProcess] <class 'gevent.timeout.Timeout'>
    

    从日志中可以看出,我使用 gevent

    升级版1: 问题似乎出在 gevent公司 游泳池(我要搬走吗 --pool=gevent ,一切正常)。

    升级版2: eventlet 游泳池似乎不支持任何超时,即使是硬的。

    0 回复  |  直到 7 年前
        1
  •  0
  •   pomo_mondreganto    7 年前

    这真的是我的问题 gevent 池,如中所述 this 拉取请求。

    推荐文章