Python Timeout Python Timeout multithreading multithreading

Python Timeout


See my answer to python: how to send packets in multi thread and then the thread kill itself - there is a fragment with InterruptableThread class and example that kill another thread after timeout - exactly what you want.

There is also similar Python recipe at activestate.


I know this might not be what you want, but have you considered the signal approach?Timeout on a function callhttp://docs.python.org/library/signal.html#example

You can set an alarm signal at the beginning of the thread execution, and then stop the thread in the signal handler.