Skip to content

Commit

Permalink
Catch timeout errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
breyten committed Mar 19, 2024
1 parent 00de705 commit 24726e9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions backend/jodal/oor.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,14 @@ def _get_hashed_id(self, dc_identifier):
return h_id.hexdigest()

def _get_item_description(self, pdf_url):
resp = requests.get('http://texter/convert', params={
'url': pdf_url,
'filetype': 'pdf'
}, timeout=OOR_TIMEOUT)
try:
resp = requests.get('http://texter/convert', params={
'url': pdf_url,
'filetype': 'pdf'
}, timeout=OOR_TIMEOUT)
except requests.exceptions.ReadTimeout as e:
logging.warning(f'Time out converting pdf to text: {pdf_url}')
return ''
if resp.status_code == 200:
t = resp.json()
return t.get('text', '')
Expand Down

0 comments on commit 24726e9

Please sign in to comment.