From 7171fb6fe053757f078db10197f702b5e4d2a841 Mon Sep 17 00:00:00 2001 From: BobTheBuidler <70677534+BobTheBuidler@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:48:56 -0400 Subject: [PATCH] feat: increase sleep time after 529 --- dank_mids/helpers/_session.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dank_mids/helpers/_session.py b/dank_mids/helpers/_session.py index a0cfba7e..13075b24 100644 --- a/dank_mids/helpers/_session.py +++ b/dank_mids/helpers/_session.py @@ -164,9 +164,6 @@ async def get_session() -> "DankClientSession": return await _get_session_for_thread(get_ident()) -_RETRY_AFTER = 1.0 - - class DankClientSession(ClientSession): _limited = False _last_rate_limited_at = 0 @@ -243,7 +240,8 @@ async def handle_too_many_requests(self, endpoint: str, error: ClientResponseErr now = time() self._last_rate_limited_at = now - retry_after = float(error.headers.get("Retry-After", 1 / limiter._rate_per_sec)) + secs_between_requests = 1 / limiter._rate_per_sec + retry_after = float(error.headers.get("Retry-After", secs_between_requests * 10)) resume_at = max( self._continue_requests_at + retry_after, self._last_rate_limited_at + retry_after,