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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user