mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
Minor enhancements to rate limiting information
If rate limiting information hasn't been retrieved already, it will be checked rather than just assuming 5000 requests remaining of 5000. Add an additional attribute `rate_limiting_resettime` to reflect github's new X-RateLimit-Reset header. This integer value is a unix timestamp. RateLimiting unit test updated accordingly.
This commit is contained in:
+4
-1
@@ -87,7 +87,8 @@ class Requester:
|
||||
self.__connectionClass = self.__httpConnectionClass
|
||||
else:
|
||||
assert False, "Unknown URL scheme"
|
||||
self.rate_limiting = (5000, 5000)
|
||||
self.rate_limiting = (-1, -1)
|
||||
self.rate_limiting_resettime = 0
|
||||
self.FIX_REPO_GET_GIT_REF = True
|
||||
self.per_page = per_page
|
||||
|
||||
@@ -175,6 +176,8 @@ class Requester:
|
||||
|
||||
if "x-ratelimit-remaining" in responseHeaders and "x-ratelimit-limit" in responseHeaders:
|
||||
self.rate_limiting = (int(responseHeaders["x-ratelimit-remaining"]), int(responseHeaders["x-ratelimit-limit"]))
|
||||
if "x-ratelimit-reset" in responseHeaders:
|
||||
self.rate_limiting_resettime = int(responseHeaders["x-ratelimit-reset"])
|
||||
|
||||
if "x-oauth-scopes" in responseHeaders:
|
||||
self.oauth_scopes = responseHeaders["x-oauth-scopes"].split(", ")
|
||||
|
||||
Reference in New Issue
Block a user