未验证 提交 5a9ec15f 编写于 作者: A Amador Pahim

Merge branch 'amoskong-wait_func'

Signed-off-by: NAmador Pahim <apahim@redhat.com>
...@@ -4,7 +4,7 @@ import time ...@@ -4,7 +4,7 @@ import time
log = logging.getLogger('avocado.test') log = logging.getLogger('avocado.test')
def wait_for(func, timeout, first=0.0, step=1.0, text=None): def wait_for(func, timeout, first=0.0, step=1.0, text=None, args=[], kwargs={}):
""" """
Wait until func() evaluates to True. Wait until func() evaluates to True.
...@@ -15,6 +15,8 @@ def wait_for(func, timeout, first=0.0, step=1.0, text=None): ...@@ -15,6 +15,8 @@ def wait_for(func, timeout, first=0.0, step=1.0, text=None):
:param first: Time to sleep before first attempt :param first: Time to sleep before first attempt
:param step: Time to sleep between attempts in seconds :param step: Time to sleep between attempts in seconds
:param text: Text to print while waiting, for debug purposes :param text: Text to print while waiting, for debug purposes
:param args: Positional arguments to func
:param kwargs: Keyword arguments to func
""" """
start_time = time.time() start_time = time.time()
end_time = time.time() + timeout end_time = time.time() + timeout
...@@ -25,7 +27,7 @@ def wait_for(func, timeout, first=0.0, step=1.0, text=None): ...@@ -25,7 +27,7 @@ def wait_for(func, timeout, first=0.0, step=1.0, text=None):
if text: if text:
log.debug("%s (%f secs)", text, (time.time() - start_time)) log.debug("%s (%f secs)", text, (time.time() - start_time))
output = func() output = func(*args, **kwargs)
if output: if output:
return output return output
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册