From b768e76c2f9dbb4ac5c8d0e4ef62872e2900f629 Mon Sep 17 00:00:00 2001 From: Josh Roesslein Date: Tue, 13 Oct 2009 17:45:35 -0500 Subject: [PATCH] Allow defining retry count and delay defaults on API object. Example: api.retry_count = 5 --> retry failed requests 5 times maxium --- tweepy/api.py | 5 ++++- tweepy/binder.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tweepy/api.py b/tweepy/api.py index 64a850d..b56d9fa 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -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 diff --git a/tweepy/binder.py b/tweepy/binder.py index 52ad01e..040a6ef 100644 --- a/tweepy/binder.py +++ b/tweepy/binder.py @@ -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', {}) -- 2.25.1