decorators and alarms
Jason Friedman
jsf80238 at gmail.com
Fri May 22 23:20:38 EDT 2015
> But, I'd like to expand this to take some generic code, not just a
> shell command, and terminate it if it does not return quickly.
>
> @time_limiter
> def generic_function(arg1, arg2, time_limit=10):
> do_some_stuff()
> do_some_other_stuff()
> return val1, val2
>
> If generic_function does not finish within 10 seconds it would stop
> executing and throw an exception.
Found an answer:
https://wiki.python.org/moin/PythonDecoratorLibrary#Function_Timeout
More information about the Python-list
mailing list