http超时重试
This commit is contained in:
parent
1bd0248625
commit
6702945ed8
@ -2,16 +2,17 @@ try:
|
|||||||
# 优先使用httpx,在httpx无法使用的环境下使用requests
|
# 优先使用httpx,在httpx无法使用的环境下使用requests
|
||||||
import httpx
|
import httpx
|
||||||
|
|
||||||
http = httpx
|
http = httpx.Client(timeout=10, transport=httpx.HTTPTransport(retries=5))
|
||||||
# 当openssl版本小于1.0.2的时候直接进行一个空请求让httpx报错
|
# 当openssl版本小于1.0.2的时候直接进行一个空请求让httpx报错
|
||||||
import tools
|
import tools
|
||||||
|
|
||||||
if tools.Get_openssl_Version() <= 102:
|
if tools.Get_openssl_Version() <= 102:
|
||||||
httpx.get()
|
httpx.get()
|
||||||
except:
|
except:
|
||||||
import requests
|
import requests
|
||||||
|
from requests.adapters import HTTPAdapter
|
||||||
http = requests
|
http = requests.Session()
|
||||||
|
http.mount('http://', HTTPAdapter(max_retries=5))
|
||||||
|
http.mount('https://', HTTPAdapter(max_retries=5))
|
||||||
|
|
||||||
|
|
||||||
# 这里实际上应该加个"-> dict"但是考虑到请求可能失败的关系,所以直接不声明返回变量
|
# 这里实际上应该加个"-> dict"但是考虑到请求可能失败的关系,所以直接不声明返回变量
|
||||||
|
Loading…
Reference in New Issue
Block a user