mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-03 20:35:17 +02:00
test: Add check_interval parameter to wait_until
This also replaces two sleep calls in functional tests with wait_until
This commit is contained in:
@@ -289,7 +289,7 @@ def ensure_for(*, duration, f, check_interval=0.2):
|
||||
time.sleep(check_interval)
|
||||
|
||||
|
||||
def wait_until_helper_internal(predicate, *, attempts=float('inf'), timeout=float('inf'), lock=None, timeout_factor=1.0):
|
||||
def wait_until_helper_internal(predicate, *, attempts=float('inf'), timeout=float('inf'), lock=None, timeout_factor=1.0, check_interval=0.05):
|
||||
"""Sleep until the predicate resolves to be True.
|
||||
|
||||
Warning: Note that this method is not recommended to be used in tests as it is
|
||||
@@ -313,7 +313,7 @@ def wait_until_helper_internal(predicate, *, attempts=float('inf'), timeout=floa
|
||||
if predicate():
|
||||
return
|
||||
attempt += 1
|
||||
time.sleep(0.05)
|
||||
time.sleep(check_interval)
|
||||
|
||||
# Print the cause of the timeout
|
||||
predicate_source = "''''\n" + inspect.getsource(predicate) + "'''"
|
||||
|
||||
Reference in New Issue
Block a user