[PyQt] Exception propagation in the exec_() loop

Yuya Nishihara yuya at tcha.org
Fri Jan 24 11:25:28 GMT 2014

On Thu, 23 Jan 2014 13:43:32 -0600, Bryan A. Jones wrote:
> It seems that exceptions which occur in an event loop (when calling
> app.exec_(), for instance) are caught and printed, but not passed on. Is
> there any way to allow exceptions to propagate past exec_()? As a concrete
> example, the following code prints the following backtrace, but doesn't
> exit.
> import sys
> from PyQt4.QtCore import QTimer
> from PyQt4.QtGui import QApplication
> def af():
>     assert False
> def main():
>     app = QApplication(sys.argv)
>     QTimer.singleShot(0, af)
>     app.exec_()

You can install sys.excepthook for uncaught exceptions.



More information about the PyQt mailing list