Try Hackernews API twice
This commit is contained in:
parent
4579dfce00
commit
cbc802b7e9
|
@ -25,6 +25,16 @@ def api(route, ref=None):
|
|||
return r.json()
|
||||
except KeyboardInterrupt:
|
||||
raise
|
||||
except BaseException as e:
|
||||
logging.error('Problem hitting hackernews API: {}, trying again'.format(str(e)))
|
||||
|
||||
try:
|
||||
r = requests.get(route(ref), timeout=15)
|
||||
if r.status_code != 200:
|
||||
raise Exception('Bad response code ' + str(r.status_code))
|
||||
return r.json()
|
||||
except KeyboardInterrupt:
|
||||
raise
|
||||
except BaseException as e:
|
||||
logging.error('Problem hitting hackernews API: {}'.format(str(e)))
|
||||
return False
|
||||
|
|
Loading…
Reference in New Issue
Block a user