Skip to content

Commit

Permalink
Merge pull request #21 from jebena/feature/jeff-better-timeout-message
Browse files Browse the repository at this point in the history
Additional hints on socket timeout issue when running in non-interactive cases
  • Loading branch information
jpotter authored Sep 23, 2024
2 parents 3dd3509 + af7430a commit 4abe7b4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions jebenaclient/jebenaclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4abe7b4

Please sign in to comment.