def __init__(self, auth_handler=None, host='twitter.com', cache=None,
secure=False, api_root='', validate=True,
- retry_count=0, retry_delay=0):
+ retry_count=0, retry_delay=0, retry_errors=[500,502,503]):
# you may access these freely
self.auth_handler = auth_handler
self.host = host
self.validate = validate
self.retry_count = retry_count
self.retry_delay = retry_delay
+ self.retry_errors = retry_errors
# not a good idea to touch these
self._username = None
# check for retry request parameters
retry_count = kargs.pop('retry_count', api.retry_count)
retry_delay = kargs.pop('retry_delay', api.retry_delay)
+ retry_errors = kargs.pop('retry_errors', api.retry_errors)
# check for headers
headers = kargs.pop('headers', {})
# Get response
resp = conn.getresponse()
- # If request was successful, quit the loop
- if resp.status == 200:
+ # Exit request loop if non-retry error code
+ if resp.status not in retry_errors:
break
# Sleep before retrying request again