timeout
- pyoptex.utils.comp.timeout(func, *args, timeout=1, default=None)[source]
Sets a timeout on a function by using a ThreadPool with one thread. If the function did not complete before the timeout, the default value is returned.
Parameters
- funcfunc
The function to run.
- argsiterable
The arguments to pass to the function.
- timeoutint
The timeout in seconds.
- defaultobj
Any object to be returned if the function does not complete in time.
Returns
- resultobj
The result from the function or default if not completed in time.