deephyper.core.utils.terminate_on_timeout#
- deephyper.core.utils.terminate_on_timeout(timeout, func, *args, **kwargs)[source]#
High order function to wrap the call of a function in a thread to monitor its execution time.
>>> import functools >>> f_timeout = functools.partial(terminate_on_timeout, 10, f) >>> f_timeout(1, b=2)
- Parameters:
timeout (int) – timeout in seconds.
func (function) – function to call.
*args – positional arguments to pass to the function.
**kwargs – keyword arguments to pass to the function.