Details
Description
It is not completely freezing. However, when I do some heavy tasks in QThread, the GUI responds slowly. For instance,
import sys from PySide2.QtCore import QThread from PySide2.QtWidgets import (QApplication, QWidget, QPushButton, QComboBox, QVBoxLayout) class Task(QThread): def run(self): # some heavy tasks print('task started') k = 0 for i in range(10000): for j in range(50000): k += 1 print('task finished') class Gui(QWidget): def __init__(self): super().__init__() layout = QVBoxLayout() button = QPushButton('click me') button.clicked.connect(self.do_task) combobox = QComboBox() combobox.addItems(['1', '2', '3', '4', '5']) layout.addWidget(button) layout.addWidget(combobox) self.setLayout(layout) def do_task(self): self.thread = Task() self.thread.start() if __name__ == '__main__': app = QApplication(sys.argv) window = Gui() window.show() sys.exit(app.exec_())
Here is the example GIF animation.
However, if I use PyQt5 to run the script (replacing PySide2 module), the GUI response will not delay at all.
Attachments
Issue Links
- is required for
-
PYSIDE-1203 Documentation/Examples For How To Develop Multithreaded Applications
- Reported
- relates to
-
PYSIDE-1108 Improve handling of threading issues between Python and Qt world
- Closed
-
PYSIDE-1657 Possible deadlock on signal connect/emit
- Closed
-
PYSIDE-1919 Segfault when garbage collector grabs object with connected signal
- Closed
-
PYSIDE-2034 QMessageBox.information in main thread blocks worker thread.
- Closed
-
PYSIDE-2302 QThreadPool locking main thread when creating QImage in PySide2 and PySide6
- Closed
-
PYSIDE-1788 overriden methods should allow threads during long Qt operations
- Closed
- resulted in
-
PYSIDE-1681 GIL deadlock in qInstallMessageHandler
- Closed
- mentioned in
-
Page Loading...