Try Hackernews API twice

master
Tanner Collin 4 years ago
parent 4579dfce00
commit cbc802b7e9
  1. 10
      apiserver/feeds/hackernews.py

@ -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…
Cancel
Save