Interrput a thread

Adam Skutt askutt at gmail.com
Tue Jan 4 21:11:55 EST 2011


On Jan 4, 10:12 am, Fuzzyman <fuzzy... at gmail.com> wrote:
>
> This is a case that .NET (C#) handles better than Python or Java.
>

Nope, read the documentation for Thread.Abort() carefully.
Thread.Abort() can cause termination inside a static constructor,
which is very bad.  You sure your application can cope with that?
Mine can't.  Thread.Abort() is only safe for self-abortion, app domain
termination and a few other very narrow and obscure scenarios.  It is
not a safe way to end arbitrary threads doing arbitrary processing.

> It's another place where people
> sometimes have a genuine need/use case yet people will insist on
> telling them they don't *really* want it...
>

Because there's no safe way to do it.  It's fundamentally a racy
operation, with the typical horrible consequences when you lose.
Removing the race requires support from the application, i.e., you
have to write the code yourself.  Frequently, it's simply not possible
to remove the race.

Adam



More information about the Python-list mailing list