Python 2.3.3 signals, threads & extensions: signal handling problem

Andrew MacIntyre andymac at
Sun Jun 6 03:40:15 CEST 2004

On Thu, 3 Jun 2004, Holger Joukl wrote:

> migrating from good old python 1.5.2 to python 2.3, I have a problem
> running a program that features some threads which execute calls to
> an extension module.
> Problem is that all of a sudden, I cannot stop the program with a keyboard
> interrupt any more; the installed signal handler does not seem to receive
> the signal at all.
> This happens both if I rebuild this extension using python 2.3
> headers/library
> and if I simply use the old extension (ignoring the API version warnings
> :-)

Don't mix signals and threads without a lot of careful doc reading and
planning.  I strongly recommend re-reading the signal module docs.

One other thing to keep in mind is that in a multithreaded build, aside
from only the main thread receiving signals, is that the signal handler is
effectively queued until the next Python VM opcode is processed.  A call
to a function in the extension is effectively a VM opcode, and if the
call doesn't return the handler will never execute.

Andrew I MacIntyre                     "These thoughts are mine alone..."
E-mail: andymac at  (pref) | Snail: PO Box 370
        andymac at             (alt) |        Belconnen  ACT  2616
Web:               |        Australia

More information about the Python-list mailing list