[PyQt] Exception propagation in the exec_() loop
Bryan A. Jones
bjones at ece.msstate.edu
Fri Jan 24 16:10:44 GMT 2014
Thanks -- that was exactly what I needed! The revised, working code:
from PyQt4.QtCore import QTimer
from PyQt4.QtGui import QApplication
sys.excepthook = lambda type, value, traceback: app.quit()
app = QApplication(sys.argv)
if __name__ == '__main__':
On Fri, Jan 24, 2014 at 5:25 AM, Yuya Nishihara <yuya at tcha.org> wrote:
> 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
> > 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.
Bryan A. Jones, Ph.D.
Department of Electrical and Computer Engineering
231 Simrall / PO Box 9571
Mississippi State University
Mississippi state, MS 39762
bjones AT ece DOT msstate DOT edu
Our Master, Jesus Christ, is on his way. He'll show up right on
time, his arrival guaranteed by the Blessed and Undisputed Ruler,
High King, High God.
- 1 Tim. 6:14b-15 (The Message)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PyQt