Commit bee97cf1 authored by Jim Fulton's avatar Jim Fulton

Added an onfail argument to wait_until to provide alternate behavior

for a timeout.
parent 04581d75
...@@ -330,13 +330,14 @@ def setUp(test): ...@@ -330,13 +330,14 @@ def setUp(test):
test.globs['wait_disconnected'] = wait_disconnected test.globs['wait_disconnected'] = wait_disconnected
def wait_until(label, func, timeout=30): def wait_until(label, func, timeout=30, onfail=None):
now = time.time() giveup = time.time() + timeout
giveup = now + 30
while not func(): while not func():
now = time.time()
if time.time() > giveup: if time.time() > giveup:
if onfail is None:
raise AssertionError("Timed out waiting for: ", label) raise AssertionError("Timed out waiting for: ", label)
else:
return onfail()
time.sleep(0.01) time.sleep(0.01)
def wait_connected(storage): 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