What problem causes exit code -1073741819 (0xC0000005) while pyqtSignal.emit()?

18 Views Asked by At

I use pyqt5 and python 3.9 in PyCharm.
This is my minimal code

import sys
from PyQt5.QtCore import QObject, QRunnable, pyqtSignal, QThreadPool
from PyQt5.QtWidgets import QMainWindow, QApplication


class Launcher(QRunnable, QObject):
    test_signal = pyqtSignal()

    def __init__(self):
        super().__init__()

    def run(self):
        print("This will be printed!")
        self.test_signal.emit()


class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        launcher = Launcher()
        launcher.test_signal.connect(self.sayHi)
        self.threadpool = QThreadPool()
        self.threadpool.start(launcher)

    def sayHi(self):
        print("Hi")  # This won't be printed


def main():
    app = QApplication(sys.argv)
    window = MainWindow()

    window.show()
    sys.exit(app.exec_())


if __name__ == "__main__":
    main()

And I get an error
Process finished with exit code -1073741819 (0xC0000005)

What should I do to avoid it? I dont get this error if my test_signal is independent class nested from QObject. But I dont understand the difference between this pyqtSignal instances.

0

There are 0 best solutions below