[Zope-DB] KeyboardInterrupt in DCOracle2
dieter at handshake.de
Mon Nov 10 14:34:47 EST 2003
jerry at longyouth.com wrote at 2003-11-10 21:38 +0800:
> I found that when the cursor is executing some insert sql and got a Ctrl-C from console,than I have no anyway to catch that exception,I have try using (except KeyboardInterrupt:/except:/except Exception/finally:),but none works,even worse is that the program just exist with a message saying "KeyboardInterrupt" and the cursor just commit everything(is this defined in the cursor clean-up function?).
> my question is:how can I catch KeyboardInterrupt from DCOracle2?
You should set up your Zope in a way such that it does not
get a "KeyboardInterrupt" under normal conditions.
If this should really be not possible for you, then
"try: ... except KeyboardInterrupt: ..." usually
Note, however, that at least in Python 2.1.3 a bug may
prevent the "try: ... except KeyboardInterrupt" to have
an effect. This happens when the interrupt already caused
a C level extensions (e.g. "dco2") to raise an exception.
The "KeyboardInterrupt" is in this case seen to late,
outside the "try: ... catch: ...".
A workaround is to add an additional "try: ... except: ...".
More information about the Zope-DB