KeyboardInterrupt eats my error and then won't be caught
philip at semanchuk.com
Sun Jun 21 10:49:42 EDT 2009
On Jun 20, 2009, at 10:21 PM, greg wrote:
> Philip Semanchuk wrote:
>> Best of all, PyErr_CheckSignals() doesn't interfere with a Python-
>> level signal handler if one is set.
> Ah, I hadn't realised that you were doing this in C
> code, and I was trying to think of a Python-level
> For C code, the solution you give sounds like a
> good one.
> My only misgiving is that the user might expect to
> get a KeyboardInterrupt in response to Ctrl-C, so
> it might be better to just let it propagate instead
> of turning it into a different exception.
I completely agree. The simple solution (for me) is to handle all
return codes of EINTR the same way which is to raise posix_ipc.Error
with the message "The wait was interrupted by a signal". But that
loses information. KeyboardInterrupt is very specific while
posix_ipc.Error is generic and even parsing the message doesn't tell
When my C code sees EINTR, I will probably raise KeyboardError when I
see that and add a specific posix_ipc.SignalError to raise in other
More information about the Python-list