import urllib3 import socket from func_timeout import func_set_timeout import func_timeout,time @func_set_timeout(11) def pdwang(): try: http = urllib3.PoolManager() http.request('GET', 'https://baidu.com') return True except: return False while 1: try: aa=pdwang() except func_timeout.exceptions.FunctionTimedOut: print("异常退出") aa=False if not aa: denglu() time.sleep(600)
标签:aa,判断,func,PYTHON,网络,set,timeout,import From: https://www.cnblogs.com/xkdn/p/16897445.html