add timeout to catalog pages
This commit is contained in:
parent
42a8353ecc
commit
6eb79ccfd5
5
app.py
5
app.py
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue