Interrupt python thread

BlueBird phil at freehackers.org
Mon Aug 25 04:00:07 EDT 2008


On Aug 24, 8:35 pm, Dennis Lee Bieber <wlfr... at ix.netcom.com> wrote:
> On Sun, 24 Aug 2008 01:48:46 -0700 (PDT), BlueBird
> <p... at freehackers.org> declaimed the following in comp.lang.python:
>
>
>
> > Whenever an exception occurs, in the master thread or in one of the
> > slave threads, I would like to interrupt all the threads and the main
> > program. Threading API does not seem to provide a way to stop a
> > thread, is there anyway to achieve that ?
>
>         The only safe way to "abort" a thread is by having it exit on its
> 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).

    Philippe



More information about the Python-list mailing list