1.检测方法的超时方法
from timeout_decorator import timeout #pip3 install timeout_decorator
import time
@timeout(5)
def main():
i=0
while True:
i+=1
time.sleep(1)
print(i)
if __name__='__main__':
main()
# 在window下运行报错
# AttributeError: module 'signal' has no attribute 'SIGALRM'
# 原因:电脑系统是win10 64位,在使用python的signal模块时报错:“AttributeError: module 'signal' has no attribute 'SIGALRM'”,这 是因为signal模块可以在linux下正常使用,但在windows下却有一些限制,在python文档# https://docs.python.org/2/library/signal.html#signal.signal找到了如下解释:
# "On Windows, signal() can only be called with SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV, or SIGTERM. A ValueError will be raised in any other case."
2.网站开发中,用于检测登陆状态,没登录定向到登陆页面
pass