github: avoid TypeError when github returns 502 or similar

...without the ratelimit header
This commit is contained in:
lilydjwg 2018-06-12 15:15:58 +08:00
parent 6848c49dfb
commit 9b8cfc6f6f
1 changed files with 2 additions and 1 deletions

View File

@ -122,7 +122,8 @@ def get_next_page_url(links):
def check_ratelimit(exc, name): def check_ratelimit(exc, name):
res = exc.response res = exc.response
n = int(res.headers.get('X-RateLimit-Remaining')) # default -1 is used to re-raise the exception
n = int(res.headers.get('X-RateLimit-Remaining', -1))
if n == 0: if n == 0:
reset = int(res.headers.get('X-RateLimit-Reset')) reset = int(res.headers.get('X-RateLimit-Reset'))
logger.error('rate limited, resetting at %s. ' logger.error('rate limited, resetting at %s. '