delay()
Invokes `func` after `wait` milliseconds.
Implementation
Parameters: func: Callable[[Any], R] The function to invoke. wait: int The number of milliseconds to wait. *args: Any Arguments to pass to `func`. **kwargs: Any Keyword arguments to pass to `func`. Returns: R The result of `func`.
Example
def print_time():
print(time.time())
delayed = delay(print_time, 1000)
delayed() # Waits 1 second before printing time
Expected output: Prints 'Delayed' after 1 second
Source Code
def delay(func, wait, *args, **kwargs):
time.sleep(wait / 1000.0)
return func(*args, **kwargs)