From: Harmon Date: Tue, 2 Feb 2021 21:14:31 +0000 (-0600) Subject: Optimize execute function X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=612c8523a3bf709c6f19056630af70954b7c13af;p=tweepy.git Optimize execute function --- diff --git a/tweepy/binder.py b/tweepy/binder.py index 4581633..578cb5b 100644 --- a/tweepy/binder.py +++ b/tweepy/binder.py @@ -48,20 +48,13 @@ def execute(api, method, path, *, params=None, headers=None, json_payload=None, api.cached_result = False - # Pick correct URL root to use - if upload_api: - api_root = api.upload_root - else: - api_root = api.api_root - + # Build the request URL if upload_api: - host = api.upload_host + url = api.upload_root + path + full_url = 'https://' + api.upload_host + url else: - host = api.host - - # Build the request URL - url = api_root + path - full_url = 'https://' + host + url + url = api.api_root + path + full_url = 'https://' + api.host + url # Query the cache if one is available # and this request uses a GET method. @@ -90,7 +83,7 @@ def execute(api, method, path, *, params=None, headers=None, json_payload=None, # Continue attempting request until successful # or maximum number of retries is reached. retries_performed = 0 - while retries_performed < api.retry_count + 1: + while retries_performed <= api.retry_count: if (api.wait_on_rate_limit and reset_time is not None and remaining_calls is not None and remaining_calls < 1):