From aceb21dbb20b145cfb75e25ad6d40d012fed550a Mon Sep 17 00:00:00 2001 From: ut003165 Date: Tue, 11 Jul 2023 17:09:30 +0800 Subject: [PATCH] Removed the args and kwargs assignments and passed them directly to func() --- avocado/utils/wait.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/avocado/utils/wait.py b/avocado/utils/wait.py index b123c4370e..1dda67a7ca 100644 --- a/avocado/utils/wait.py +++ b/avocado/utils/wait.py @@ -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 @@ -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 \ No newline at end of file