imp
2 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
6 additions and
4 deletions
-
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() |
|
|
|