Skip to content

Commit

Permalink
improve logging message in case of network timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
mam10eks committed Jun 4, 2024
1 parent 555ba27 commit 9293e11
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion python-client/tira/rest_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,12 @@ def json_response(self, endpoint: str, params: Optional[Union[Dict, List[tuple],
break
except Exception as e:
sleep_time = randint(1, self.failsave_max_delay)
logging.warn(f'Error occured while fetching {endpoint}. Code: {resp.status_code}. I will sleep {sleep_time} seconds and continue.', exc_info=e)
response_code = "'unknown response code, maybe there was a timeout?'"
try:
response_code = resp.status_code
except:
pass
logging.warn(f'Error occured while fetching {endpoint}. Code: {response_code}. I will sleep {sleep_time} seconds and continue.', exc_info=e)
time.sleep(sleep_time)

return resp.json()
Expand Down

0 comments on commit 9293e11

Please sign in to comment.