Is it possible to kill a thread ?
Grant Edwards
grante at visi.com
Thu Dec 6 15:14:53 EST 2001
More information about the Python-list mailing list
Thu Dec 6 15:14:53 EST 2001
- Previous message (by thread): Is it possible to kill a thread ?
- Next message (by thread): Is it possible to kill a thread ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In article <3C0FCD72.A5FA167C at ccvcorp.com>, Jeff Shannon wrote: > > 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. The problem with this is that one often creates a thread so that it can do some possibly blocking operation without stopping the rest of the program. If the thread is blocked, it can't check the event. If the thread isn't going to block, then why create a thread? [Yes, there are other reasons for splitting something into a thread, but in many cases I create a thread specifically because it's goign to block.] -- Grant Edwards grante Yow! .. are the STEWED at PRUNES still in the HAIR visi.com DRYER?
- Previous message (by thread): Is it possible to kill a thread ?
- Next message (by thread): Is it possible to kill a thread ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list