Allow defining retry count and delay defaults on API object.
authorJosh Roesslein <jroesslein@gmail.com>
Tue, 13 Oct 2009 22:45:35 +0000 (17:45 -0500)
committerJosh Roesslein <jroesslein@gmail.com>
Tue, 13 Oct 2009 22:45:35 +0000 (17:45 -0500)
Example: api.retry_count = 5  --> retry failed requests 5 times maxium

tweepy/api.py
tweepy/binder.py

index 64a850d9c44061404b6b50992f1602a0a6692998..b56d9fa189708bd5da5929ebdf51d6b16d5d6436 100644 (file)
@@ -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
index 52ad01e43b61f379ebcc0666466952a1bb5cf44b..040a6ef237e793a023521e9a14fadf4232321d06 100644 (file)
@@ -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', {})