From 34f36b1c32affd69ddcb01991a1b06bfc6bf1ab4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20B=C3=BCchse?= Date: Thu, 13 Jun 2024 09:08:09 +0200 Subject: [PATCH] Bugfix: debug logging of retry potentially misleading (#629) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Matthias Büchse --- Tests/iaas/entropy/entropy-check.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Tests/iaas/entropy/entropy-check.py b/Tests/iaas/entropy/entropy-check.py index ac7aa7771..b5913c902 100755 --- a/Tests/iaas/entropy/entropy-check.py +++ b/Tests/iaas/entropy/entropy-check.py @@ -350,17 +350,21 @@ def retry(func, exc_type, timeouts=(8, 7, 15, 10, 20, 30, 60)): timeout_iter = iter(timeouts) # do an initial sleep because func is known fail at first anyway time.sleep(next(timeout_iter)) + retries = 0 while True: try: func() except Exception as e: + retries += 1 timeout = next(timeout_iter, None) if timeout is None or e.__class__.__name__ not in exc_type: raise - logger.debug(f"Caught {e!r} while {func!r}; waiting {timeout} s before retry") + logger.debug(f"Initiating retry in {timeout} s due to {e!r} during {func!r}") time.sleep(timeout) else: break + if retries: + logger.debug(f"Operation {func!r} successful after {retries} retries") class CountingHandler(logging.Handler):