How to kill a thread from another thread ?

Oleg Broytmann phd at phd.russ.ru
Fri Nov 10 03:36:06 EST 2000


On Thu, 9 Nov 2000, Richard Gruet wrote:
> Actually, I'm using a thread to execute a function call asynchronously, to avoid
> getting stuck is something goes wrong. To execute the call, I create a thread and
> delegate the actual function call to it. Then, in the main thread, I wait for the
> end of the thread (ie the return of the function called) with a timeout (using a
> join).
> The problem is that if a timeout occurs because the function doesn't return, I
> have no way to kill the thread and sometimes it appears to prevent the program to
> exit correctly (it hangs because there is still living threads).

   Use forking. It is pretty perfect way to timeout subprocesses.

Oleg.
----
     Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.





More information about the Python-list mailing list