A better way to timeout a class method?

John O'Hagan mail at johnohagan.com
Tue Mar 10 03:23:26 CET 2009


On Mon, 9 Mar 2009, Marco Mariani wrote:
> John O'Hagan wrote:
> > Is there a concise Pythonic way to write a method with a timeout?
>
> No need for threading. Just define a signal handler and call
> signal.alarm().
>
Thanks, that works well in general; but unfortunately the method in question 
(see the P.S. in my original post) starts a thread, and it's the thread that 
needs to timeout; unfortunately signal doesn't work in a thread. So I guess I 
need to rephrase my question as: how to timeout a thread?

Regards,

John





More information about the Python-list mailing list