From 14ebeba07d527a189a5cdf93c0f85392302b2ca1 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Tue, 1 Aug 2023 15:28:49 -0400 Subject: [PATCH] avoid re-computing the current time inside this loop It could lead to funny behavior if we cross a boundary at just the wrong time. Also the debug print could be misleading in such a case. --- integration/util.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/integration/util.py b/integration/util.py index 31d351bc1..756489120 100644 --- a/integration/util.py +++ b/integration/util.py @@ -622,8 +622,9 @@ def await_client_ready(tahoe, timeout=10, liveness=60*2, minimum_number_of_serve time.sleep(1) continue + now = time.time() print( - f"Now: {time.ctime()}\n" + f"Now: {time.ctime(now)}\n" f"Server last-received-data: {[time.ctime(s['last_received_data']) for s in servers]}" ) @@ -633,7 +634,7 @@ def await_client_ready(tahoe, timeout=10, liveness=60*2, minimum_number_of_serve ] # check that all times are 'recent enough' (it's OK if _some_ servers # are down, we just want to make sure a sufficient number are up) - if len([time.time() - t <= liveness for t in server_times if t is not None]) < minimum_number_of_servers: + if len([now - t <= liveness for t in server_times if t is not None]) < minimum_number_of_servers: print("waiting because at least one server too old") time.sleep(1) continue