Skip to content

Commit

Permalink
fix: suppress StopIteration warning
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler committed Dec 4, 2024
1 parent d0b774e commit 363ea8c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions dank_mids/helpers/_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ async def post(self, endpoint: str, *args, loads: JSONDecoder = DEFAULT_JSON_DEC
return response_data
except ClientResponseError as ce:
if ce.status == HTTPStatusExtended.TOO_MANY_REQUESTS: # type: ignore [attr-defined]
await self.handle_too_many_requests(endpoint, args, loads, kwargs, ce)
await self.handle_too_many_requests(ce)
else:
try:
if ce.status not in RETRY_FOR_CODES or tried >= 5:
Expand All @@ -174,10 +174,10 @@ async def post(self, endpoint: str, *args, loads: JSONDecoder = DEFAULT_JSON_DEC
)
tried += 1

async def handle_too_many_requests(self, endpoint, args, loads, kwargs, ce) -> None:
async def handle_too_many_requests(self, error: ClientResponseError) -> None:
now = time()
self._last_rate_limited_at = now
retry_after = float(ce.headers.get("Retry-After", _RETRY_AFTER))
retry_after = float(error.headers.get("Retry-After", _RETRY_AFTER))
resume_at = max(
self._continue_requests_at + retry_after,
self._last_rate_limited_at + retry_after,
Expand Down

0 comments on commit 363ea8c

Please sign in to comment.