其他分享
首页 > 其他分享> > request 改变max retries

request 改变max retries

作者:互联网

下面两段代码都可以进行改变
代码1:
from requests.adapters import HTTPAdapter s = requests.Session() s.mount('http://stackoverflow.com', HTTPAdapter(max_retries=5))

代码2:
import requests
from urllib3.util.retry import Retry
from requests.adapters import HTTPAdapter

s = requests.Session()

retries = Retry(total=5,
                backoff_factor=0.1,
                status_forcelist=[ 500, 502, 503, 504 ])

s.mount('http://', HTTPAdapter(max_retries=retries))

s.get('http://httpstat.us/500')
 

标签:retries,http,HTTPAdapter,max,request,import,requests
来源: https://www.cnblogs.com/L-O-N/p/12938162.html