aboutsummaryrefslogtreecommitdiff
path: root/discord/http.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2019-08-27 03:33:44 -0400
committerRapptz <[email protected]>2019-08-27 18:41:32 -0400
commitea3d119ca61e269f3d5bfdfe42178a82d2dba5e6 (patch)
tree760e1882acc76f326b7a0efe0f25cea174463191 /discord/http.py
parentFix bucket key to not have the method in there. (diff)
downloaddiscord.py-ea3d119ca61e269f3d5bfdfe42178a82d2dba5e6.tar.xz
discord.py-ea3d119ca61e269f3d5bfdfe42178a82d2dba5e6.zip
Use X-Ratelimit-Reset-After header by default.
There is now an option to turn it off, of course.
Diffstat (limited to 'discord/http.py')
-rw-r--r--discord/http.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/discord/http.py b/discord/http.py
index 0c4b1a53..70a04bda 100644
--- a/discord/http.py
+++ b/discord/http.py
@@ -86,7 +86,7 @@ class HTTPClient:
SUCCESS_LOG = '{method} {url} has received {text}'
REQUEST_LOG = '{method} {url} with {json} has returned {status}'
- def __init__(self, connector=None, *, proxy=None, proxy_auth=None, loop=None):
+ def __init__(self, connector=None, *, proxy=None, proxy_auth=None, loop=None, unsync_clock=True):
self.loop = asyncio.get_event_loop() if loop is None else loop
self.connector = connector
self.__session = None # filled in static_login
@@ -97,6 +97,7 @@ class HTTPClient:
self.bot_token = False
self.proxy = proxy
self.proxy_auth = proxy_auth
+ self.use_clock = not unsync_clock
user_agent = 'DiscordBot (https://github.com/Rapptz/discord.py {0}) Python/{1[0]}.{1[1]} aiohttp/{2}'
self.user_agent = user_agent.format(__version__, sys.version_info, aiohttp.__version__)
@@ -166,7 +167,7 @@ class HTTPClient:
remaining = r.headers.get('X-Ratelimit-Remaining')
if remaining == '0' and r.status != 429:
# we've depleted our current bucket
- delta = utils._parse_ratelimit_header(r)
+ delta = utils._parse_ratelimit_header(r, use_clock=self.use_clock)
log.debug('A rate limit bucket has been exhausted (bucket: %s, retry: %s).', bucket, delta)
maybe_lock.defer()
self.loop.call_later(delta, lock.release)