functools#
timeout#
from toolbox.functools import timeout
- timeout(days, hours, minutes, seconds, error)[source]#
Wait for time before quitting func run and returning None.
This decorator works with both asynchronous and synchronous functions. Note, however, that with synchronous function the signal module is used and therefore will not work with non-Unix based systems.
- Parameters:
days (
int
) – Days to wait before timeout.hours (
int
) – Hours to wait before timeout.minutes (
int
) – Minutes to wait before timeout.seconds (
int
) – Seconds to wait before timeout.error (
bool
) – Indicates whether or not to throwTimeoutError
error once function timeouts.
Example
from toolbox.functools.timeout import timeout @timeout(seconds=5) def func(): time.wait(15) func()
- Return type:
Union
[Callable
,Awaitable
]