Interrupt python thread

Dieter Maurer dieter at handshake.de
Sat Aug 30 04:35:02 EDT 2008


En Mon, 25 Aug 2008 05:00:07 -0300, BlueBird <phil at freehackers.org>
escribi¡Z:
> 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).

At the C level, Python has function to send an exception to a thread.
The threads will see the exception only when it executes Python code
(i.e. not when it is waiting or running in external (e.g. "C") code).

You may use (e.g.) "PyRex" to make a Python wrapper available
to your Python code.

Dieter



More information about the Python-list mailing list