[twisted-python] Communication between GUI thread and twisted thread.

甜瓜 littlesweetmelon at gmail.com
Mon Jun 18 02:37:34 EDT 2007


Hi, my program has two parts running in two threads. One is a GUI
layer, the other is a twisted layer for communication with a remote
server. Sometimes, a button is clicked in GUI to notice the twisted
thread to send out some data. (reactor.callFromThread should be used,
right?)

In twisted part, I use reactor.connectTCP('x.x.x.x', port,
MyFactory()) to connect with remote server. MyFactory will create an
instance of MyProtocol, and MyProtocol has a method 'sendSpecialMsg'
for doing real jobs.

However, in GUI part, how can I invoke 'sendSpecialMsg' function? Even
I cannot get the MyProtocol instance! Because connectTCP and MyFactory
hide the protocol object. I'm sure it is a common problem for
beginners, Could you give me some advice?

Thank you.
---
ShenLei




More information about the Twisted-Python mailing list