簡體   English   中英

Celery 的 @shared_task 不能使用 soft_time_limit

[英]Celery's @shared_task not working with soft_time_limit

下面是一些簡單的代碼:

@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_tasktime_limitsoft_time_limit成立,所以我希望Here 5秒后要打印(連同SoftTimeLimitExceeded異常信息),然后There與一些硬超時異常進行打印。

相反,它根本不提高SoftTimeLimitExceeded ,只調用硬時間限制,完整輸出為:

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工作人員。

UPD #1:問題似乎與gevent池有關(我是否刪除了--pool=gevent ,一切正常)。

UPD #2: eventlet池似乎不支持任何超時,即使是硬超時。

如此拉取請求中所提到的,確實是gevent池的問題。

問題可以認為是封閉的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM