Stopping a thread from another one

Roger Binns rogerb at rogerbinns.com
Wed Jun 23 14:58:32 EDT 2004


Peter Hansen wrote:
> Threads are too difficult, and multithreaded issues too little
> understood by most people, to expect that people will not shoot
> themselves in the foot with a thread.kill().  Newbies will see
> that method and find all manner of creative ways to use it, none
> of which will be either required or reliable.
>
> Killing threads is an STD, and in this area Python makes you wear
> a condom.

If I write the code for the threads then what exactly is the
problem?

As far as I can tell, implementing thread killing is something that
is difficult to implement in the interpretter, but rather than just
admit that, we get the "who will think of the newbies" cries instead.

Anybody can use os.remove.  Do we prevent access to that?  Heck,
I can subclass and not call parent constructors.  Does Python
even bat an eyelid.  I can open zillions of sockets and dump
spam down them.  Not a peep from Python.

I can make multiple threads of execution and put in all
sorts of deadlocks.  I can even write infinite loops trivially.
No sound from Python.

We already have signals and keyboardinterrupt in the main
thread and the world hasn't collapsed.  I don't exactly see
how it will suddenly collapse if the same can be done to
other threads.

Roger





More information about the Python-list mailing list