From 19edfec9b80a07a2730bc2f8a93c1d10b3828ad3 Mon Sep 17 00:00:00 2001 From: woutdenolf Date: Mon, 12 Aug 2024 17:23:59 +0200 Subject: [PATCH] debug CI --- src/silx/utils/retry.py | 10 +++++++--- src/silx/utils/test/test_retry.py | 8 +++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/silx/utils/retry.py b/src/silx/utils/retry.py index 7fd9fbb6d7..fad9f5cecb 100644 --- a/src/silx/utils/retry.py +++ b/src/silx/utils/retry.py @@ -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 @@ -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 diff --git a/src/silx/utils/test/test_retry.py b/src/silx/utils/test/test_retry.py index 893a8f44aa..5951b81dde 100644 --- a/src/silx/utils/test/test_retry.py +++ b/src/silx/utils/test/test_retry.py @@ -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 @@ -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))