From b28a4a115e72977a9091091983a1213e91f8a5e9 Mon Sep 17 00:00:00 2001 From: Michael H Date: Fri, 20 Jun 2025 14:31:55 -0400 Subject: [PATCH] Fix potentially stuck ratelimit buckets --- discord/http.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/discord/http.py b/discord/http.py index 6617efa27..eb1dbbd06 100644 --- a/discord/http.py +++ b/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():