Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed the args and kwargs assignments and passed them directly to f… #5720

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions avocado/utils/wait.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,22 @@
LOG = logging.getLogger(__name__)


def wait_for(func, timeout, first=0.0, step=1.0, text=None, args=None, kwargs=None):
def wait_for(func, timeout, first=0.0, step=1.0, text=None, *args, **kwargs):
"""
Wait until func() evaluates to True.

If func() evaluates to True before timeout expires, return the
value of func(). Otherwise return None.

:param timeout: Timeout in seconds
:param first: Time to sleep before first attempt
:param step: Time to sleep between attempts in seconds
:param text: Text to print while waiting, for debug purposes
:param args: Positional arguments to func
:param kwargs: Keyword arguments to func
:param func: The function to be evaluated.
:param timeout: Timeout in seconds.
:param first: Time to sleep before the first attempt.
:param step: Time to sleep between attempts in seconds.
:param text: Text to print while waiting, for debug purposes.
:param args: Positional arguments to func.
:param kwargs: Keyword arguments to func.
:return: The value returned by func() if it evaluates to True within the timeout, otherwise None.
"""
if args is None:
args = []
if kwargs is None:
kwargs = {}
start_time = time.monotonic()
end_time = start_time + timeout

Expand All @@ -37,4 +35,4 @@ def wait_for(func, timeout, first=0.0, step=1.0, text=None, args=None, kwargs=No

time.sleep(step)

return None
return None