Skip to content

Instantly share code, notes, and snippets.

@kevinburke
Created January 22, 2014 19:35
Show Gist options
  • Save kevinburke/8565777 to your computer and use it in GitHub Desktop.
Save kevinburke/8565777 to your computer and use it in GitHub Desktop.
def default_retry_callback(response=None, error=None):
""" Retry errors where the connection to the server was not established """
return (isinstance(error, exceptions.ConnectionError)
or isinstance(error, exceptions.SocketError)
or isinstance(error, HTTPException))
def idempotent_retry_callback(response=None, error=None):
if (isinstance(error, exceptions.ConnectionError)
or isinstance(error, exceptions.SocketError)
or isinstance(error, HTTPException)):
return True
if response is not None:
if response.status_code == 503 or response.status_code == 429:
return True
class Retries(object):
def __init__(self, retry_count=3, retry_callback=default_retry_callback):
""" Initialize the retry object """
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment