Created
April 13, 2021 11:47
-
-
Save bjhulst/9fe7e537afd20f0c59dd2c76e94814be to your computer and use it in GitHub Desktop.
python_requests_with_retries.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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