Improve failure behaviour when unable to refresh cache

This commit is contained in:
RunasSudo 2019-01-11 22:39:49 +11:00
parent 66c39629fc
commit ad61f30a4c
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
1 changed files with 3 additions and 4 deletions

View File

@ -36,13 +36,12 @@ def do_request(endpoint, args=None, cachetime=3600):
try:
resp = urlopen(req)
except Exception as ex:
print('Unable to refresh cache')
traceback.print_exc()
if url in request_cache:
print('Unable to refresh cache')
traceback.print_exc()
return request_cache[url][1]
else:
return None
raise ex
data = json.load(resp)
# Cache the response