request 改变max retries

下面两段代码都可以进行改变
代码1:
from requests.adapters import HTTPAdapter s = requests.Session() s.mount('http://*.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')
 
上一篇:重试


下一篇:Python3中关于Max retries exceeded with url 的错误解决