Created
January 22, 2014 19:35
-
-
Save kevinburke/8565777 to your computer and use it in GitHub Desktop.
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
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