From 694a47762062d9ca029c2f1a4858e63ecadd8108 Mon Sep 17 00:00:00 2001 From: imp <106537315+imptype@users.noreply.github.com> Date: Tue, 2 Sep 2025 17:30:50 +0100 Subject: [PATCH] Move to _wake function --- discord/http.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/discord/http.py b/discord/http.py index 480d22706..2a864f56d 100644 --- a/discord/http.py +++ b/discord/http.py @@ -385,8 +385,7 @@ class Ratelimit: def no_headers(self) -> None: self.one_shot = True - if self._future and not self._future.done(): - self._future.set_result(None) + self._wake() def reset(self) -> None: self.remaining = self.limit - self.outgoing @@ -432,6 +431,10 @@ class Ratelimit: delta = self.http.loop.time() - self._last_request return delta >= 300 and (self.one_shot or (self.outgoing == 0 and self.pending == 0)) + def _wake(self) -> None: + if self._future and not self._future.done(): + self._future.set_result(None) + async def _wait_global(self, start_time: float): # Sleep up to 3 times, to account for global reset at overwriting during sleeps for i in range(3): @@ -502,8 +505,7 @@ class Ratelimit: async def release(self): if not self.one_shot: self.outgoing -= 1 - if self._future and not self._future.done(): - self._future.set_result(None) + self._wake() async def __aenter__(self) -> Self: await self.acquire()