From a5c807abe0ea4f78b3e62b8cff815b13b268a41a Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Thu, 26 Feb 2026 16:22:26 +0100 Subject: [PATCH] test/infamy: make until() exception-safe Any exception raised by fn() propagated immediately out of the retry loop, effectively making until() a single-shot call the moment any transient error occurred. Fix by wrapping fn() in a try/except inside the loop and treating any exception as a "not yet" result. The last exception is preserved and re-raised if all attempts are exhausted, so failure output is still meaningful. Also fix a missing newline at end of file. Fixes #1403 Signed-off-by: Joachim Wiberg --- test/infamy/util.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/infamy/util.py b/test/infamy/util.py index 9fa1e967..77bc3ede 100644 --- a/test/infamy/util.py +++ b/test/infamy/util.py @@ -38,13 +38,20 @@ def parallel(*fns): def until(fn, attempts=10, interval=1): + last_exc = None for attempt in range(attempts): - result = fn() + try: + result = fn() + except Exception as e: + last_exc = e + result = False if result: return result time.sleep(interval) + if last_exc: + raise last_exc raise Exception("Expected condition did not materialize") @@ -119,4 +126,4 @@ def curl(url, timeout=10, silent=False): except (urllib.error.URLError, ConnectionResetError, UnicodeEncodeError, TimeoutError) as e: if not silent: print(f"[WARN] curl: failed to fetch {url}: {e}") - return "" \ No newline at end of file + return ""