Created
February 11, 2024 20:11
-
-
Save ghomem/3a26740cfe07c91d2af2ed8929dcc4f2 to your computer and use it in GitHub Desktop.
reliable invocation
This file contains hidden or 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
requester = requests.session() | |
retries = Retry(total=nr_retries, backoff_factor=backoff_factor, | |
status_forcelist=FORCE_RETRY_STATUS_CODE_LIST) | |
requester.mount("https://", HTTPAdapter(max_retries=retries)) | |
requester.mount("http://", HTTPAdapter(max_retries=retries)) | |
try: | |
response = requester.get(url=url, timeout=client_timeout) | |
print("Request done") | |
except (HTTPError, MaxRetryError) as err: | |
print("There was a problem in the request to service: " + str(err)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment