Commit e7a6a4b7 authored by Jim Fulton's avatar Jim Fulton

Added an onfail argument to wait_until to provide alternate behavior

for a timeout.
parent 100a2556
......@@ -330,13 +330,14 @@ def setUp(test):
test.globs['wait_disconnected'] = wait_disconnected
def wait_until(label, func, timeout=30):
now = time.time()
giveup = now + 30
def wait_until(label, func, timeout=30, onfail=None):
giveup = time.time() + timeout
while not func():
now = time.time()
if time.time() > giveup:
if onfail is None:
raise AssertionError("Timed out waiting for: ", label)
else:
return onfail()
time.sleep(0.01)
def wait_connected(storage):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment