Commit b768e76c authored by Josh Roesslein's avatar Josh Roesslein
Browse files

Allow defining retry count and delay defaults on API object.

Example: api.retry_count = 5  --> retry failed requests 5 times maxium
parent 8fd79bab
......@@ -15,7 +15,8 @@ class API(object):
"""Twitter API"""
def __init__(self, auth_handler=None, host='twitter.com', cache=None,
secure=False, api_root='', validate=True):
secure=False, api_root='', validate=True,
retry_count=0, retry_delay=0):
# you may access these freely
self.auth_handler = auth_handler
self.host = host
......@@ -23,6 +24,8 @@ class API(object):
self.cache = cache
self.secure = secure
self.validate = validate
self.retry_count = retry_count
self.retry_delay = retry_delay
# not a good idea to touch these
self._username = None
......
......@@ -33,8 +33,8 @@ def bind_api(path, parser, allowed_param=[], method='GET', require_auth=False,
post_data = kargs.pop('post_data', None)
# check for retry request parameters
retry_count = kargs.pop('retry_count', 0)
retry_delay = kargs.pop('retry_delay', 0)
retry_count = kargs.pop('retry_count', api.retry_count)
retry_delay = kargs.pop('retry_delay', api.retry_delay)
# check for headers
headers = kargs.pop('headers', {})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment