From af7430ab60f3203bd74d27d3d93b2e8825c7f99a Mon Sep 17 00:00:00 2001 From: Jeff Potter Date: Mon, 23 Sep 2024 16:32:43 -0400 Subject: [PATCH] Additional hints on socket timeout issue when running in non-interactive cases --- jebenaclient/jebenaclient.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/jebenaclient/jebenaclient.py b/jebenaclient/jebenaclient.py index a8920ce..41588ed 100755 --- a/jebenaclient/jebenaclient.py +++ b/jebenaclient/jebenaclient.py @@ -74,7 +74,8 @@ # re-work python logging setup for py2 issue # 0.9.1 20210813: Re-work logger to add NullHandler for py2 reasons # 0.9.2 20230222: Improve timeout handling error messages, for clarity -__version__ = "0.9.2" +# 0.9.3 20240923: Add timeout and hint on socket error, for more clarity on timeout cases +__version__ = "0.9.3" import json import logging @@ -412,6 +413,7 @@ def _log_and_raise(log_message, *args): ) time.sleep(retry_delay) + start_time = time.time() try: context = None if allow_insecure_https: @@ -456,7 +458,12 @@ def _log_and_raise(log_message, *args): ) except socket.timeout: - _log_and_raise_or_retry("Socket Timeout error") + run_time = time.time() - start_time + _log_and_raise_or_retry( + "Socket Timeout error (%s seconds; max allowed is %s; hint: set ENV JEBENA_CLIENT_TIMEOUT)", + run_time, + __MAX_RUN_TIME_IN_SECONDS + ) continue except urllib_HTTPError as exc: # qa