python - Altering PySide.QtGui.QListWidget with an emitted signal from a multiprocessing.Pool async call results in Runtime Error? -



python - Altering PySide.QtGui.QListWidget with an emitted signal from a multiprocessing.Pool async call results in Runtime Error? -

i have:

from pyside.qtcore import signal, qobject multiprocessing import pool def some_computation(): pass # ..some computations homecoming 'result' class myclass(qobject): my_signal = signal() def __init__(self): self.mylistwidget = # ... qlistwidget somewhere # bind signal slot self.my_signal.connect(self.on_my_signal) # called after computation thread finished def my_callback_fct(result): # ..bla bla self.my_signal.emit() # function phone call def do_some_async_computation(self) pool = pool(processes=2) pool.apply_async(target=some_computation, callback=my_callback_fct) # slot def on_my_signal(self): self.mylistwidget.clear()

i read around stackoverflow in order alter gui secondary execution thread 1 must utilize slot-signal mechanism, did in myclass, although when phone call do_some_async_computation expect pool initiate secondary thread some_computation function ..which happens, after computation finished my_callback_fct executed accordingly, emits my_signal signal connected on_my_signal slot, executed expected, when altering self.mylistwidget gives runtime error / qwidget runtime error redundant repaint detected

i haven't observed actual error, in similar scenario utilize queuedconnection ensure signal passed correctly 1 thread other. done automagically people if objects in question belong different threads (qobject have notion of qthread owns them). in case, done on 1 object, qt can't know. do

from pyqt5.qtcore import qt ... self.my_signal.connect(self.on_my_signal, qt.queuedconnection)

python pyside python-multithreading qlistwidget

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -