[英]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_task
用time_limit
和soft_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
池似乎不支持任何超時,即使是硬超時。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.