@@ -289,7 +289,7 @@ def ensure_for(*, duration, f, check_interval=0.2):
289
289
time .sleep (check_interval )
290
290
291
291
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 ):
293
293
"""Sleep until the predicate resolves to be True.
294
294
295
295
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
298
298
properly scaled. Furthermore, `wait_until()` from `P2PInterface` class in
299
299
`p2p.py` has a preset lock.
300
300
"""
301
- if attempts == float ('inf' ) and timeout == float ('inf' ):
302
- timeout = 60
303
301
timeout = timeout * timeout_factor
304
- attempt = 0
305
302
time_end = time .time () + timeout
306
303
307
- while attempt < attempts and time .time () < time_end :
304
+ while time .time () < time_end :
308
305
if lock :
309
306
with lock :
310
307
if predicate ():
311
308
return
312
309
else :
313
310
if predicate ():
314
311
return
315
- attempt += 1
316
312
time .sleep (check_interval )
317
313
318
314
# Print the cause of the timeout
319
315
predicate_source = "''''\n " + inspect .getsource (predicate ) + "'''"
320
316
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 ))
326
318
327
319
328
320
def sha256sum_file (filename ):
0 commit comments