Is it possible to kill a thread ?

Courageous jkraska at san.rr.com
Thu Dec 6 14:58:23 EST 2001


>Create a threading.Event object, and pass it to the thread at startup.  When
>you want to close the application, set the event, and then join() the thread.
>In the thread, you periodically check the event.  When the event becomes set,
>then the thread terminates itself.  At that point, your main thread returns
>from join() and you can finish shutting down.

This is good advice. Not only that, but it's advice practiced by
many. 

It's generally considered bad form to kill a foreign thread. One
generally asks it to die nicely. If you think about it, this is
the "object oriented way of doing things". Presumably only the
thread in question really knows how to clean up after itself properly.

C//




More information about the Python-list mailing list