Killing threads (was Re: Cancel or timeout a long running regular expression)

Chris Angelico rosuav at gmail.com
Sat Sep 17 19:19:46 EDT 2011


On Sun, Sep 18, 2011 at 8:27 AM, Chris Rebert <clp2 at rebertia.com> wrote:
> It's possible that the reason is analogous to why Java has deprecated
> its equivalent, Thread.stop():
> http://download.oracle.com/javase/1.4.2/docs/guide/misc/threadPrimitiveDeprecation.html

Interesting. The main argument against having a way to raise an
arbitrary exception in a different thread is that it gets around
Java's requirement to declare all exceptions that a routine might
throw - a requirement that Python doesn't have. So does that mean it'd
be reasonable to have a way to trigger a "TerminateThread" exception
(like SystemExit but for one thread) remotely? The above article
recommends polling a variable, but that's the exact sort of thing that
exceptions are meant to save you from doing.

ChrisA



More information about the Python-list mailing list