Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/util.py
Show First 20 Lines • Show All 250 Lines • ▼ Show 20 Lines | while attempt < attempts and time.time() < time_end: | ||||
return | return | ||||
else: | else: | ||||
if predicate(): | if predicate(): | ||||
return | return | ||||
attempt += 1 | attempt += 1 | ||||
time.sleep(0.05) | time.sleep(0.05) | ||||
# Print the cause of the timeout | # Print the cause of the timeout | ||||
predicate_source = inspect.getsourcelines(predicate) | predicate_source = "''''\n" + inspect.getsource(predicate) + "'''" | ||||
logger.error("wait_until() failed. Predicate: {}".format(predicate_source)) | logger.error("wait_until() failed. Predicate: {}".format(predicate_source)) | ||||
if attempt >= attempts: | if attempt >= attempts: | ||||
raise AssertionError("Predicate {} not true after {} attempts".format( | raise AssertionError("Predicate {} not true after {} attempts".format( | ||||
predicate_source, attempts)) | predicate_source, attempts)) | ||||
elif time.time() >= time_end: | elif time.time() >= time_end: | ||||
raise AssertionError( | raise AssertionError( | ||||
"Predicate {} not true after {} seconds".format(predicate_source, timeout)) | "Predicate {} not true after {} seconds".format(predicate_source, timeout)) | ||||
raise RuntimeError('Unreachable') | raise RuntimeError('Unreachable') | ||||
▲ Show 20 Lines • Show All 343 Lines • Show Last 20 Lines |