I am using twisted and PySide2 to create an app that can send information through network. However, twisted's reactor
and PySide2's QApplication
both need an event loop that runs forever.
What I need is when twisted receives a new message, I want it to update the message in the PySide2 Window. So that means twisted and PySide2 need to share the same memory. Here's some sample code:
def dataReceived(self, data): # a function inside a twisted class
QLabel.setText(data.decode()) # a pyside2 object
I cannot use threading, because twisted and PySide2 both needed to be in the main thread; And multiprocessing can't share memory like QWidget objects.
So how can I run these two event loops at the same time, and let them share the same memory?
CodePudding user response:
You can run the Twisted and Qt5 event loops side-by-side using https://pypi.org/project/qt5reactor/.