> 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
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to