Improve failure behaviour when unable to refresh cache
This commit is contained in:
parent
66c39629fc
commit
ad61f30a4c
@ -36,13 +36,12 @@ def do_request(endpoint, args=None, cachetime=3600):
|
|||||||
try:
|
try:
|
||||||
resp = urlopen(req)
|
resp = urlopen(req)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
|
if url in request_cache:
|
||||||
print('Unable to refresh cache')
|
print('Unable to refresh cache')
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
if url in request_cache:
|
|
||||||
return request_cache[url][1]
|
return request_cache[url][1]
|
||||||
else:
|
else:
|
||||||
return None
|
raise ex
|
||||||
data = json.load(resp)
|
data = json.load(resp)
|
||||||
|
|
||||||
# Cache the response
|
# Cache the response
|
||||||
|
Reference in New Issue
Block a user