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')
 
posted @ 2020-05-22 16:48  进击的pythoner  阅读(1287)  评论(0编辑  收藏  举报