Browse Source
Fix potentially stuck ratelimit buckets
pull/10215/head
Michael H
2 weeks ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
6 additions and
1 deletions
-
discord/http.py
|
|
@ -461,7 +461,12 @@ class Ratelimit: |
|
|
|
future = self._loop.create_future() |
|
|
|
self._pending_requests.append(future) |
|
|
|
try: |
|
|
|
await future |
|
|
|
while not future.done(): |
|
|
|
# 30 matches the smallest allowed max_ratelimit_timeout |
|
|
|
max_wait_time = self.expires - self._loop.time() if self.expires else 30 |
|
|
|
await asyncio.wait([future], timeout=max_wait_time) |
|
|
|
if not future.done(): |
|
|
|
await self._refresh() |
|
|
|
except: |
|
|
|
future.cancel() |
|
|
|
if self.remaining > 0 and not future.cancelled(): |
|
|
|