threads killing other threads
Jeff Shannon
jeff at ccvcorp.com
Thu Feb 7 15:17:26 EST 2002
More information about the Python-list mailing list
Thu Feb 7 15:17:26 EST 2002
- Previous message (by thread): threads killing other threads
- Next message (by thread): threads killing other threads
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Greg Weeks wrote: > I've occasionally wanted thread objects to have an exit() method, so that > one thread could interrrupt and kill another. This doesn't seem to be > available, perhaps because POSIX threads don't support it. > > Is that correct? > > Is there some reason why threads killing threads would be undesirable or > hard to implement? I don't know the reasoning behind threads being unkillable (from outside), but I do know the (apparently standard) way to accomplish what you want. Create a global threading.Event object, named something descriptive like Quit, and have every thread peek at it occasionally. If the Quit event is set, then the thread aborts. If you need to be able to kill specific threads individually, then you have a separate event object for each thread. Of course, this *does* rely on the threads being well-behaved, and not getting stuck in an infinite loop elsewhere, and so on.... but then, that's pretty much a requirement anyhow. Jeff Shannon Technician/Programmer Credit International
- Previous message (by thread): threads killing other threads
- Next message (by thread): threads killing other threads
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list