How do I implement a retry count of 5 times, 10 seconds apart when sending a POST
request using the requests
package.
I have found plenty of exampl
I found that the default behaviour of Retries did not apply to POST. To do so required the addition of method_whitelist, e.g. below:
def retry_session(retries=5):
session = Session()
retries = Retry(total=retries,
backoff_factor=0.1,
status_forcelist=[500, 502, 503, 504],
method_whitelist=frozenset(['GET', 'POST']))
session.mount('https://', HTTPAdapter(max_retries=retries))
session.mount('http://', HTTPAdapter(max_retries=retries))
return session