Cancelling a python thread (revisited...)

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Sun Nov 8 14:50:07 CET 2009


On 12:40 pm, sven at uni-hd.de wrote:
>On Nov 8, 4:27 am, Carl Banks <pavlovevide... at gmail.com> wrote:
>>It doesn't sound like the thread is communicating with the process
>>much.  Therefore:
>
>There is quite a bit of communication -- the computation results are
>visulized while they are generated.

I'm curious how this visualization works, since earlier you said 
something to the affect that there were no shared resources.  If you 
kill a thread and it had opened a window and was drawing on it, with 
most toolkits, you'll end up with a window stuck in your screen, won't 
you?
>[snip]
>
>I really don't get that.  If the reason would be that it is too much
>work to
>implement, then I could accept it.  But saying: We know it is useful,
>but we
>won't allow to do it, just does not seem reasonable.  Thread
>cancellation
>might be generally unsafe, but there are cases when it is safe.  It
>should be
>up to the user to decide it.  There are many things that do harm if
>you don't
>use them correctly, and of course it would be a bad idea to remove all
>of
>them from Python.

The CPython philosophy sort of follows the guideline that you should be 
allowed to do bad stuff if you want, except when that bad stuff would 
crash the interpreter (clearly ctypes is an exception to this rule of 
thumb).  I think this is the argument that has been applied in 
opposition to adding thread termination in the past, though I don't 
remember for sure.

Jean-Paul



More information about the Python-list mailing list