1
0
mirror of synced 2025-12-22 03:21:25 -05:00

fix(source-github): fix min time to wait on token rate limits (#67589)

## What
there is an issue while processing min time to wait on token rate
limits:
.seconds - returns positive value 
fixed to
.total_seconds() - returns both negative and positive values. (negative
when reset time for token is older then datetime now)

## How
<!--
* Describe how code changes achieve the solution.
-->

## Review guide
<!--
1. `x.py`
2. `y.py`
-->

## User Impact
<!--
* What is the end result perceived by the user?
* If there are negative side effects, please list them. 
-->

## Can this PR be safely reverted and rolled back?
<!--
* If unsure, leave it blank.
-->
- [ ] YES 💚
- [ ] NO 
This commit is contained in:
Daryna Ishchenko
2025-10-09 16:29:34 +03:00
committed by GitHub
parent 1d4013c56f
commit 7e5c616453
4 changed files with 4 additions and 3 deletions

View File

@@ -144,7 +144,7 @@ class MultipleTokenAuthenticatorWithRateLimiter(AbstractHeaderAuthenticator):
setattr(current_token, count_attr, getattr(current_token, count_attr) - 1)
return True
elif all(getattr(x, count_attr) == 0 for x in self._tokens.values()):
min_time_to_wait = min((getattr(x, reset_attr) - ab_datetime_now()).seconds for x in self._tokens.values())
min_time_to_wait = min((getattr(x, reset_attr) - ab_datetime_now()).total_seconds() for x in self._tokens.values())
if min_time_to_wait < self.max_time:
time.sleep(min_time_to_wait if min_time_to_wait > 0 else 0)
self.check_all_tokens()