Interrput a thread
John Nagle
nagle at animats.com
Fri Dec 31 13:28:26 EST 2010
On 12/29/2010 3:31 PM, gervaz wrote:
> Hi all, I need to stop a threaded (using CTR+C or kill) application if
> it runs too much or if I decide to resume the work later.
> I come up with the following test implementation but I wanted some
> suggestion from you on how I can implement what I need in a better or
> more pythonic way.
You can't send signals to individual threads under CPython.
Even where the OS supports it, CPython does not. See
"http://docs.python.org/library/signal.html"
Nor can you kill a thread. All you can do is ask it
nicely to stop itself.
Even worse, sending control-C to a multi-thread program
is unreliable in CPython. See "http://blip.tv/file/2232410"
for why. It's painful.
John Nagle
More information about the Python-list
mailing list