Skip to content

Instantly share code, notes, and snippets.

@ghomem
Created February 11, 2024 20:11
Show Gist options
  • Save ghomem/3a26740cfe07c91d2af2ed8929dcc4f2 to your computer and use it in GitHub Desktop.
Save ghomem/3a26740cfe07c91d2af2ed8929dcc4f2 to your computer and use it in GitHub Desktop.
reliable invocation
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