I want to make use of the requests module backoff strategy outlined at https://stackoverflow.com/a/35504626/1021819, the code reproduced from that answer being:
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')
[This link gives further useful info: https://www.peterbe.com/plog/best-practice-with-retries-with-requests]
According to the documentation for backoff_factor at https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html#module-urllib3.util.retry,
A backoff factor to apply between attempts after the second try (most errors are resolved immediately by a second try without a delay). urllib3 will sleep for:
{backoff factor} * (2 ** ({number of total retries} - 1))
seconds. If the backoff_factor is 0.1, then sleep() will sleep for [0.0s, 0.2s, 0.4s, …] between retries. It will never be longer than Retry.BACKOFF_MAX.
How can I elegantly implement a non-exponential backoff e.g. linear?
Thanks as ever!