python超时跳过当前语句的方法
时间:2020-06-26 12:34:29
收藏:0
阅读:239
需要安装eventlet库
import time
import eventlet
# 最开始加上这条语句
eventlet.monkey_patch()
#设置超时时间为10秒
with eventlet.Timeout(10,False):
# 此处编写可能超时的语句,超时则会跳出这段语句
time.sleep(4)
原文:https://www.cnblogs.com/sumuyi/p/13194122.html
评论(0)