Skip to content

Commit

Permalink
debug CI
Browse files Browse the repository at this point in the history
  • Loading branch information
woutdenolf committed Aug 12, 2024
1 parent 5eb0a16 commit 19edfec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/silx/utils/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,16 @@ def _retry_loop(retry_timeout=None, retry_period=None, retry_on_error=None):
"""
has_timeout = retry_timeout is not None
if has_timeout:
t0 = time.time()
t0 = time.perf_counter()
else:
t0 = None
retry_state = {"t0": t0, "exception": None, "retry_on_error": retry_on_error}
if t0 is not None:
print("AAA start timer", retry_state["t0"])
while True:
yield retry_state
if has_timeout and (time.time() - retry_state["t0"]) > retry_timeout:
print("BBB check timer", time.perf_counter(), time.perf_counter() - retry_state["t0"])
if has_timeout and (time.perf_counter() - retry_state["t0"]) > retry_timeout:
err_msg = "%s seconds" % retry_timeout
cause = retry_state.get("exception")
raise RetryTimeoutError(err_msg) from cause
Expand Down Expand Up @@ -144,7 +147,8 @@ def wrapper(*args, **kw):
yield result
# restart the retry loop
if retry_state["t0"] is not None:
retry_state["t0"] = time.time()
retry_state["t0"] = time.perf_counter()
print("AAA reset timer", retry_state["t0"])
retry_state["retry_on_error"] = oretry_on_error
return

Expand Down
8 changes: 5 additions & 3 deletions src/silx/utils/test/test_retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ def method():

def test_retry_iter_reset(self):
failure_count = 0
retry_period = 0.2
failure_duration = 0.6
retry_period = 0.1 # seconds
failure_duration = 0.7 # seconds

nfailures = int(failure_duration/retry_period + 0.5)
retry_timeout = failure_duration + retry_period
Expand All @@ -234,4 +234,6 @@ def iter_silx(start_index=0):
failure_count += 1
raise retry.RetryError()

assert list(iter_silx()) == list(range(10))
yield 10

assert list(iter_silx()) == list(range(11))

0 comments on commit 19edfec

Please sign in to comment.