Skip to content

Instantly share code, notes, and snippets.

@dybber
Created October 21, 2018 13:50
Show Gist options
  • Save dybber/f27c98fc164d9bb50483b7af68b675d7 to your computer and use it in GitHub Desktop.
Save dybber/f27c98fc164d9bb50483b7af68b675d7 to your computer and use it in GitHub Desktop.
PySide2 Exception not raised to the user
import sys
import PySide2.QtCore as QtCore
import PySide2.QtWidgets as QtWidgets
class Worker(QtCore.QObject):
on_start = QtCore.Signal()
def on_start(self):
print("This line is executed!")
raise Exception(".. but this exception is not raised")
def main():
app = QtWidgets.QApplication(sys.argv)
label = QtWidgets.QLabel("Hello World!")
label.show()
worker_thread = QtCore.QThread()
worker = Worker()
worker.moveToThread(worker_thread)
worker_thread.started.connect(worker.on_start)
worker_thread.finished.connect(worker_thread.deleteLater)
worker_thread.start()
app.exec_()
# Application was closed, clean up and exit
worker.deleteLater()
worker_thread.deleteLater()
sys.exit(0)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment