Description
When calling ip.getSquadMatchsums and hitting the 429 error, the wait time can be negative
Received status code 429 (You have exhausted the API Request Quota), retrying in -0.04 seconds...
ERROR: Error occurred: sleep length must be non-negative
Steps to Reproduce
Run ip.getSquadMatchsums repeatedly so it hits the quota
Expected Behavior
Waitin times should be possitive
Actual Behavior
No response
Environment
impectPy-2.5.7
Both Windows 11 and Linux with Python 3.11.2
Additional Context
Fixed by adding a max to the retry delay in RateLimitedAPI.make_api_request:
elif response.status_code == 429:
if i < max_retries - 1:
if self.bucket and retry_delay is None:
wait_time = max(0, math.ceil(
self.bucket.refill_after * 100 - (
import_time.time() - self.bucket.last_refill_time
) * 100
) / 100)
else:
wait_time = retry_delay if retry_delay is not None else 1
print(f"Received status code {response.status_code} "
f"({response.json().get('message', 'Rate Limit Exceeded')})"
f", retrying in {wait_time} seconds...")
import_time.sleep(wait_time)
Description
When calling ip.getSquadMatchsums and hitting the 429 error, the wait time can be negative
Steps to Reproduce
Run ip.getSquadMatchsums repeatedly so it hits the quota
Expected Behavior
Waitin times should be possitive
Actual Behavior
No response
Environment
impectPy-2.5.7
Both Windows 11 and Linux with Python 3.11.2
Additional Context
Fixed by adding a max to the retry delay in RateLimitedAPI.make_api_request: