Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: increase sleep time after 529 #335

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading