Skip to content

Commit

Permalink
feat: increase sleep time after 529
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Dec 19, 2024
1 parent 9cd414c commit 7171fb6
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions dank_mids/helpers/_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 7171fb6

Please sign in to comment.