From 4def665e8b6c8c2d1eab504fe68bd0ebdcd1fc0d Mon Sep 17 00:00:00 2001 From: johndoknjas Date: Sun, 22 Sep 2024 04:08:27 -0700 Subject: [PATCH] Sleep one request earlier, in order to add more of a buffer if restarting the program (due to the extra api call for verifying the key). --- hypickle/hypixel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hypickle/hypixel.py b/hypickle/hypixel.py index 526c899..e90e587 100644 --- a/hypickle/hypixel.py +++ b/hypickle/hypixel.py @@ -56,7 +56,7 @@ def getJSON(typeOfRequest: str, uuid_or_ign: Optional[str], specific_api_key: Op f'typeOfRequest: {typeOfRequest}\nthere was a problem with response.json()' ) from e - if ('RateLimit-Remaining' in responseHeaders and int(responseHeaders['RateLimit-Remaining']) <= 1 + if ('RateLimit-Remaining' in responseHeaders and int(responseHeaders['RateLimit-Remaining']) <= 2 and int(responseHeaders['RateLimit-Reset']) < 295): # The < 295 condition is to not sleep when starting a new rate limit period, since it seems # there's a bug in the api where the first response header gives a `RateLimit-Remaining` val that