I am testing with a url that will return 503 and would want the script to request the URL with a backoff_factor
of 1 with max _retries
function. Base on my 8 times retries, theoretically the request was supposed to spend at least 64 s for the request but it just straight away print the response 503 and I do not think it actually retries for 8 times. I even increase backoff_factor
to 20 and still instantly print out response 503
from requests.packages.urllib3.util.retry import Retry
from requests.adapters import HTTPAdapter
import requests
url = 'http://httpstat.us/503'
s = requests.Session()
retries = Retry(total=8, backoff_factor=1, status_forcelist=[ 502, 503, 504 ])
s.mount('http://', HTTPAdapter(max_retries=retries))
response = s.get(url)
print response
I have been checking other post and try with s.mount('http://', requests.adapters.HTTPAdapter(max_retries=retries))
with similar result.
How to let the script really retries 8 times and confirm it actually retries?
Please advise if the solution works for HTTP
and https
When I call retries
>>> retries
Retry(total=8, connect=None, read=None, redirect=None)
Is the input correct? I base on https://stackoverflow.com/a/35636367/5730859 solution and but it does not seems to retry. Can anyone help?