Interrupt python thread
gagsl-py2 at yahoo.com.ar
Mon Aug 25 20:51:49 CEST 2008
En Mon, 25 Aug 2008 05:00:07 -0300, BlueBird <phil at freehackers.org>
> On Aug 24, 8:35 pm, Dennis Lee Bieber <wlfr... at ix.netcom.com> wrote:
>> The only safe way to "abort" a thread is by having it exit on
>> own. This means one needs a means of setting an attribute that each
>> thread periodically checks within a while loop.
> Unfortunately, this does not map very well with my program. Each of my
> threads are calling foreign code (still written in python though),
> which might be busy for 1 to 10 minutes with its own job.
> I wanted something to easily interrupt every thread to prevent my
> program to stall for 10 minutes if I want to stop it (getting tired of
> killing python all the time).
If the foreign Python code is running on your own process, can't you make
it check a flag periodically?
If it runs as another process, killing it is a lot safer than killing a
More information about the Python-list