[PyQt] Exception propagation in the exec_() loop

Bryan A. Jones bjones at ece.msstate.edu
Thu Jan 23 19:43:32 GMT 2014


All,

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_()

if __name__ == '__main__':
    main()


Results:
C:\Users\bjones\Documents\enki_all\enki\tests>tst_signal2.py
Traceback (most recent call last):
  File "C:\Users\bjones\Documents\enki_all\enki\tests\tst_signal2.py", line
6, in af
    assert False
AssertionError

...but the program keeps running; I can't try/catch these in main().

Bryan
-- 
Bryan A. Jones, Ph.D.
Associate Professor
Department of Electrical and Computer Engineering
231 Simrall / PO Box 9571
Mississippi State University
Mississippi state, MS 39762
http://www.ece.msstate.edu/~bjones
bjones AT ece DOT msstate DOT edu
voice 662-325-3149
fax 662-325-2298

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...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20140123/66bd9dbd/attachment.html>


More information about the PyQt mailing list