I haven't heard of anyone trying it yet. Can you give an example of
how this would be useful?
In any case you would have to handle them in a similar way as the
KeyboardInterrupt exception is currently handled: the real (C) signal
handler only sets a flag that the signal has arrived, and then later
the interpreter checks this flag (possibly after each (virtual)
instruction -- currently it's done only every few instructions) and
invokes the code that handles the signal. I suppose you could set it
up so that if the handler returns the interpreter continues where it
left off, while if the handler raises an exception the interpreter
passes the exception on. KeyboardInterrupt could then be made a
special case of this.
Note that you won't be able to catch program bugs in the Python
interpreter this way (since they must be handled synchronously).
There is also the problem that not all wrappers around blocking system
calls (or blocking library calls) will will yield return when a signal
handler is called, so the Python signal handling may wait until the
call returns normally -- this is usually not what you want.
I'm sorry...
--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>