How to force a thread to stop
bryanjugglercryptographer at yahoo.com
bryanjugglercryptographer at yahoo.com
Tue Jul 25 09:19:18 EDT 2006
Dennis Lee Bieber wrote:
> On Mon, 24 Jul 2006 10:27:08 -0700, "Carl J. Van Arsdall"
> > My problem with the fact that python doesn't have some type of "thread
> > killer" is that again, the only solution involves some type of polling
> > loop. I.e. "if your thread of execution can be written so that it
>
> And that is because the control of a thread, once started, is
> dependent upon the underlying OS...
No; it's because killing a thread from another thread fundamentally
sloppy.
> The process of creating a thread can
> be translated into something supplied by pretty much all operating
> systems: an Amiga task, posix thread, etc.
>
> But ending a thread is then also dependent upon the OS -- and not
> all OSs have a way to do that that doesn't run the risk of leaking
> memory, leaving things locked, etc. until the next reboot.
No operating system has a good way to do it, at least not for
the kind of threads Python offers.
> The procedure for M$ Windows to end a task basically comes down to
> "send the task a 'close window' event; if that doesn't work, escalate...
> until in the end it throw its hands up and says -- go ahead and leave
> memory in a mess, just stop running that thread".
The right procedure in MS Windows is the same as under POSIX:
let the thread terminate on its own.
> > module without killing the whole system. Any of you guys thought of a
> > way around this scenario?
>
> Ask Bill Gates... The problem is part of the OS.
Or learn how to use threads properly. Linux is starting to get good
threading. Win32 has had it for quite a while.
--
--Bryan
More information about the Python-list
mailing list