[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] [BUG] No exception reports in a QThread with Python 3
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2013-02-20 10:21:48
Message-ID: 701bbab0dc8ef235880657ed736857b3 () localhost
[Download RAW message or body]

On Sun, 3 Feb 2013 14:55:51 +0000, Richie Ward <richies@gmail.com> wrote:
> If you run the following code with Python 3, you will not recieve a
> exception; dispite it being blatently wrong.
> import sys
> from PyQt4 import QtGui, QtCore
> 
> class FooThread(QtCore.QThread):
> 
>     def run(self):
>         beeswax
>         return
> 
> 
> if __name__ == "__main__":
>     app = QtGui.QApplication(sys.argv)
> 
>     ft = FooThread()
>     ft.start()
>     sys.exit(app.exec_())
> 
> 
> 
> Avaris on #pyqt @ freenode managed to come up with this workaround:
> 
> import sys
> import time
> import traceback
> from PyQt4 import QtGui, QtCore
> 
> def excepthook(exc_type, exc_val, tracebackobj):
>     message = ''.join(traceback.format_exception(exc_type, exc_val,
> tracebackobj))
> 
>     print('EXCEPTHOOK')
>     print(message)
>     print('*'*30)
> 
> sys.excepthook = excepthook
> 
> class FooThread(QtCore.QThread):
>     def run(self):
>         time.sleep(1)
>         beeswaxThread
> 
> class FooObject(QtCore.QObject):
>     finished = QtCore.pyqtSignal()
> 
>     def run(self):
>         time.sleep(2)
>         beeswaxObject
>         self.finished.emit()
> 
> if __name__ == "__main__":
>     app = QtCore.QCoreApplication(sys.argv)
> 
>     thread = QtCore.QThread()
>     fooObject = FooObject()
>     fooObject.moveToThread(thread)
>     thread.started.connect(fooObject.run)
>     fooObject.finished.connect(thread.quit)
> 
>     fooThread = FooThread()
> 
>     thread.start()
>     fooThread.start()
> 
>     QtCore.QTimer.singleShot(3000, app.quit)
>     sys.exit(app.exec_())
> 
> My test system that I use to reproduce this is:
> PyQt 4.9.6 - Built from source.
> Ubuntu 12.10
> Pythion 3.2
> 
> The guys on IRC confirmed this was a bug for me too.

Should be fixed in tonight's SIP snapshot (and current hg).

Thanks,
Phil
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic