Skip to content

Commit 111465d

Browse files
committed
test: Remove unused attempts parameter from wait_until
1 parent 5468a23 commit 111465d

File tree

1 file changed

+3
-11
lines changed
  • test/functional/test_framework

1 file changed

+3
-11
lines changed

test/functional/test_framework/util.py

+3-11
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def ensure_for(*, duration, f, check_interval=0.2):
289289
time.sleep(check_interval)
290290

291291

292-
def wait_until_helper_internal(predicate, *, attempts=float('inf'), timeout=float('inf'), lock=None, timeout_factor=1.0, check_interval=0.05):
292+
def wait_until_helper_internal(predicate, *, timeout=60, lock=None, timeout_factor=1.0, check_interval=0.05):
293293
"""Sleep until the predicate resolves to be True.
294294
295295
Warning: Note that this method is not recommended to be used in tests as it is
@@ -298,31 +298,23 @@ def wait_until_helper_internal(predicate, *, attempts=float('inf'), timeout=floa
298298
properly scaled. Furthermore, `wait_until()` from `P2PInterface` class in
299299
`p2p.py` has a preset lock.
300300
"""
301-
if attempts == float('inf') and timeout == float('inf'):
302-
timeout = 60
303301
timeout = timeout * timeout_factor
304-
attempt = 0
305302
time_end = time.time() + timeout
306303

307-
while attempt < attempts and time.time() < time_end:
304+
while time.time() < time_end:
308305
if lock:
309306
with lock:
310307
if predicate():
311308
return
312309
else:
313310
if predicate():
314311
return
315-
attempt += 1
316312
time.sleep(check_interval)
317313

318314
# Print the cause of the timeout
319315
predicate_source = "''''\n" + inspect.getsource(predicate) + "'''"
320316
logger.error("wait_until() failed. Predicate: {}".format(predicate_source))
321-
if attempt >= attempts:
322-
raise AssertionError("Predicate {} not true after {} attempts".format(predicate_source, attempts))
323-
elif time.time() >= time_end:
324-
raise AssertionError("Predicate {} not true after {} seconds".format(predicate_source, timeout))
325-
raise RuntimeError('Unreachable')
317+
raise AssertionError("Predicate {} not true after {} seconds".format(predicate_source, timeout))
326318

327319

328320
def sha256sum_file(filename):

0 commit comments

Comments
 (0)