Stopping a thread from another one

Antoon Pardon apardon at forel.vub.ac.be
Thu Jun 24 04:24:15 EDT 2004


Op 2004-06-23, Peter Hansen schreef <peter at engcorp.com>:
> Antoon Pardon wrote:
>
>> Op 2004-06-23, Chris S. schreef <chrisks at NOSPAMudel.edu>:
>>>Incorporating a flag into each thread, which is checked periodically by 
>>>the thread to decide whether or not it should end, is the safest way to 
>>>terminate threads. However, if you're looking for a preemptive method 
>>>that kills a thread unconditionally (whether the thread wants to die or 
>>>not) then search this group for 'Kthread', a module created by Connelly 
>>>Barnes, which implements a subclass of Thread incorporating this 
>>>feature. Note that killing threads preemptively is unsafe and should 
>>>only be done with care. This is why it's not part of Python's standard 
>>>threading library.
>> 
>> I thought Python was a language for consenting adults.
>
> The "consulting adults" refrain comes from the idea that two people
> should be allowed to engage in whatever behaviour they want,
> together, if it's not harming anyone including themselves.  It's
> a social thing, you know, keep the government out of the bedroom.
>
> 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.

And who decides that?

Whenever someone comes up with an idea that will help prevent
people from shooting themselves in the foot, I hear the:
"Python is for consenting adults" mantra, don't take away
the flexibility of the language. Now suddenly the situation
is reversed and people ask for more flexibility and suddenly
the extra flexibility is like as STD and the consenting
adults idea not so strong as originally presented.

My impression with all that Python Zen is that people
just use it to resist change. Explicit is better than
implicit except where python currently already does things
implicitly. Python is for consenting adults except
where python has already limitations because those
limitations are for preventing STD.

-- 
Antoon Pardon



More information about the Python-list mailing list