python超时跳过当前语句的方法

需要安装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