[PyQt] Exception handling hook
Sundance
sundance at ierne.eu.org
Wed May 23 15:19:27 BST 2007
Arve Knudsen wrote:
> If an exception is raised in the last Python
> layer, it is swallowed by the excepthook and a nice message box pops
> up, BUT once control returns to the first Python layer
Hi again,
In my opinion, the exception hook should never even return. That's what
I meant when I said your application should then close. When you're
dealing with an uncaught exception anyway, something has gone wrong and
it is generally wise not to attempt to keep running, lest data
corruption and bad karma occur, in that approximate order.
I am not sure that what you seem to be asking for is at all possible --
it would involve making the Qt event loop aware of Python exceptions, I
think, which doesn't at all sound like good Feng Shui to me.
If you really, really want to deal with Python exceptions at the
outermost possible level (which will still be inside the Qt event loop
level, mind), then I guess you should make an exception hook that will
store the exception stack in some global variable, push some manner of
custom event to the application's main event queue (or put the
exception stack /in/ the custom event), then return, and have a custom
event handler pull the exception stack off that custom event and only
THEN process it. And quit.
Theorically feasible, I would imagine.
But I still think that quitting the application right away would make
less baby angels cry, mind.
Hope this helps nonetheless!
-- S.
More information about the PyQt
mailing list