add timeout to catalog pages

This commit is contained in:
Edward Betts 2019-09-29 21:46:39 +01:00
parent 42a8353ecc
commit 6eb79ccfd5

5
app.py
View file

@ -388,7 +388,7 @@ def get_catalog_page(property_id, value):
if os.path.exists(filename):
html = open(filename).read()
else:
r = requests.get(url, headers={'User-Agent': user_agent})
r = requests.get(url, headers={'User-Agent': user_agent}, timeout=2)
html = r.text
open(filename, 'w').write(html)
@ -429,6 +429,7 @@ def item_page(item_id):
catalog_url = first_datavalue(entity, 'P973')
catalog = None
try:
if 'P4704' in entity['claims']:
saam_id = first_datavalue(entity, 'P4704')
catalog = saam.get_catalog(saam_id)
@ -461,6 +462,8 @@ def item_page(item_id):
'institution': detail['label'],
'description': description,
}
except requests.exceptions.ReadTimeout:
pass
return render_template('item.html',
qid=qid,