github & gitlab: exc.response may be None when timed out

This commit is contained in:
lilydjwg 2018-06-19 18:29:38 +08:00
parent 9b8cfc6f6f
commit be6f9dc9e9
2 changed files with 8 additions and 1 deletions

View file

@ -122,6 +122,9 @@ def get_next_page_url(links):
def check_ratelimit(exc, name):
res = exc.response
if not res:
raise
# default -1 is used to re-raise the exception
n = int(res.headers.get('X-RateLimit-Remaining', -1))
if n == 0:

View file

@ -62,7 +62,11 @@ async def get_version_real(name, conf, **kwargs):
def check_ratelimit(exc, name):
res = exc.response
n = int(res.headers.get('RateLimit-Remaining'))
if not res:
raise
# default -1 is used to re-raise the exception
n = int(res.headers.get('RateLimit-Remaining'), -1)
if n == 0:
logger.error('rate limited, resetting at (unknown). '
'Or get an API token to increase the allowance if not yet',