How to kill a thread from another thread ?
Richard Gruet
rgruet at ina.fr
Sat Nov 11 12:17:41 EST 2000
More information about the Python-list mailing list
Sat Nov 11 12:17:41 EST 2000
- Previous message (by thread): How to kill a thread from another thread ?
- Next message (by thread): How to kill a thread from another thread ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Robert Amesz wrote: > Aahz Maruch wrote: > > >In article <3A0A6715.35C19F47 at ina.fr>, Richard Gruet > ><rgruet at ina.fr> wrote: > >> > >>Does someone know how to kill a Python thread from another Python > >>thread (in the same process) ? > > > >You don't. You need to set up each of your threads so that they > >look for some kind of signal to kill themselves (which means > >returning). It has been argued that the ability to kill threads is > >necessary for server applications, but I haven't seen any powerful > >arguments in favor of that. > > How about doing blocking I/O in a thread? If something goes wrong the > thread might block forever. Anticipating the response: "So don't do > blocking I/O", I'd like to add that you may not have that option, > because the blocking call could be in another module which you need to > use but didn't write yourself > If Python uses non-blocking I/O internally, *and* it had the ability to > raise exceptions in another thread you would have a very powerful > mechanism to kill threads and still have a thread clean up after itself > (which is, I think, the most powerful argument against having threads > kill each other). In my particular case, I want to kill the thread from the thread which created it when something is going wrong (e.g. a timed out I/O) and furthermore I performed the cautious operation in a separate thread precisely to be avoid getting stuck in case of problem. To me this is a good reason to want to kill a thread in this case. I agree that *usually* killing a thread without clean-up is not a good policy! This leads me back to my original question: how can I do that (and in a portable way) ? Apparently there is no obvious solution. To use a separate process to execute an operation is quite inefficient (although in this case I know how to kill the process). Richard Gruet
- Previous message (by thread): How to kill a thread from another thread ?
- Next message (by thread): How to kill a thread from another thread ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list