Threads

Mike Fletcher mfletch at tpresence.com
Wed Jan 3 14:57:33 EST 2001


To clarify this (I think Don knows, but others might not):

With the current uthread (micro-thread) system, you can kill a micro-thread,
but only if you can get the scheduler code to run.  If a micro-thread hangs
_in C code that hasn't released the Python interpreter lock_ then you can't
kill the thread (and your whole micro-threads simulation is hosed, as the
scheduler will not run any more).

Python code in a micro-thread that's taking forever to complete (such as a
long-running AI computation, or a thread that's blocking on a lock) can be
killed easily using the provided methods of the thread object.

I've never tried killing a thread that's running C code that _has_ released
the interpreter lock, so no idea what happens then.  The uthread would be
gone when the C code returns, no idea what it would do when it discovers
that (I mean, when you get a Dear John letter, do you go to pieces, a bar,
or on a date?  Is there really a correct answer?).

Enjoy,
Mike

-----Original Message-----
From: Donn Cave
To: python-list at python.org
Sent: 1/3/2001 2:15 PM
Subject: Re: Threads
...
>From what I have heard of the stackless microthread system, you
won't get the `processes that "hang up" can just be killed' part
of what you want there, at least not for all causes of hanging up.
Honestly, I guess you won't get it from Python threads either,
because there is no provision in the API for killing a thread, but
at least the process will continue, because these threads go down
to the operating system level where the usual hanging up happens.
...




More information about the Python-list mailing list