From 9293e11c25f0b432cae95ff9733dd509d05c4539 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maik=20Fr=C3=B6be?= Date: Tue, 4 Jun 2024 07:43:12 +0200 Subject: [PATCH] improve logging message in case of network timeouts --- python-client/tira/rest_api_client.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/python-client/tira/rest_api_client.py b/python-client/tira/rest_api_client.py index 918ae096..e1fe340a 100644 --- a/python-client/tira/rest_api_client.py +++ b/python-client/tira/rest_api_client.py @@ -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()