Skip to content

Instantly share code, notes, and snippets.

@bjhulst
Created April 13, 2021 11:47
Show Gist options
  • Save bjhulst/9fe7e537afd20f0c59dd2c76e94814be to your computer and use it in GitHub Desktop.
Save bjhulst/9fe7e537afd20f0c59dd2c76e94814be to your computer and use it in GitHub Desktop.
python_requests_with_retries.py
import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
session = requests.Session()
retry = Retry(connect=3, backoff_factor=0.5)
adapter = HTTPAdapter(max_retries=retry)
session.mount('http://', adapter)
session.mount('https://', adapter)
session.get(url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment