We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c2efa06 commit 185bff9Copy full SHA for 185bff9
1 file changed
twitter/api.py
@@ -26,6 +26,7 @@
26
import time
27
import base64
28
import re
29
+import logging
30
import requests
31
from requests_oauthlib import OAuth1, OAuth2
32
import io
@@ -77,6 +78,7 @@
77
78
# A singleton representing a lazily instantiated FileCache.
79
DEFAULT_CACHE = object()
80
81
+logger = logging.getLogger(__name__)
82
83
class Api(object):
84
"""A python interface into the Twitter API
@@ -275,7 +277,6 @@ def __init__(self,
275
277
application_only_auth)
276
278
279
if debugHTTP:
- import logging
280
try:
281
import http.client as http_client # python3
282
except ImportError:
@@ -5051,7 +5052,9 @@ def _RequestUrl(self, url, verb, data=None, json=None, enforce_auth=True):
5051
5052
5053
if limit.remaining == 0:
5054
- time.sleep(max(int(limit.reset - time.time()) + 2, 0))
5055
+ stime = max(int(limit.reset - time.time()) + 2, 0)
5056
+ logger.debug('Rate limited requesting [%s], sleeping for [%s]', url, stime)
5057
+ time.sleep(stime)
5058
except ValueError:
5059
pass
5060
0 commit comments