I was wondering if anyone had any ideas on why the following PyQt signal/slot setup would work, while adding in multiprocessing will cause the GUI not to update. The signals are sent through in both cases, but the signal/slot can update the GUI, while the multiprocessing layout does not.
Here is the general setup that I have: For PyQt Signals and Slots I have this, which works:
# signals and slots
class Worker(QObject):
...
# send signals in for loop to tab
...
class Tab(QTabWidget):
...
# start thread
...
# get signals and update GUI
class MainWindow:
...
# make GUI stuff
...
# start worker process
While this multiprocessing code does not:
# signals and slots *with multiprocessing*
class Worker(QObject):
...
# send messages down a pipe in for loop to tab
...
class Worker_thread(QThread):
...
# start process
...
# get messages from Worker and send signals to update GUI function in Tab
class Tab(QTabWidget):
...
# start Worker_Thread
...
# get signals and update GUI
class MainWindow:
...
# make GUI stuff
...
# start Worker_thread process
Here is the function that gets messages from the Worker and sends signals to update the GUI in the multiprocessing case:
@QtCore.pyqtSlot()
def start_computation(self):
self.process.start()
while(True):
try:
message = self.consumer.recv()
self.update_signal.emit(message)
except EOFError:
pass
if message == 'done with processing':
self.done_signal.emit()
break
#self.parent.update_GUI(message)
self.process.join()
return
Do I need to close the Pipe
somewhere in here? It has to constantly be reading the process for it's progress and updating the GUI throughout, so I don't know where that would be appropriate.
Also, there are some full code examples of this here:
multiprocessing GUI schemas to combat the "Not Responding" blocking
and here:
Any help is much appreciated.