Is it possible to kill a thread ?
Jeff Shannon
jeff at ccvcorp.com
Thu Dec 6 14:56:34 EST 2001
guignot wrote:
> I have a prog which launches a server, using thread.start_new call.
> When I destroy the gui, it keeps stuck, probably because the server thread
> is still running...
> Can the main prog cleanly die, or is there a way to kill the thread ?
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.
Jeff Shannon
Technician/Programmer
Credit International
More information about the Python-list
mailing list