
On 10/29/07, Rutt, Benjamin <Benjamin.Rutt@gs.com> wrote:
I'm still puzzled how exactly 'reactor.callFromThread(self.transport.writeSomeData(...))' gets routed to the right client when called from my function. How does twisted know which client that message is going to? After all, it calls it from the main reactor loop. i.e. what state does it use to get this right?
"self.transport" is associated with the particular connection. Also, there are a couple of other things wrong about your snippet: 1. use "write", not "writeSomeData". writeSomeData is an internal implementation detail. 2. You're actually calling writeSomeData and passing the *result* of that to callFromThread. That's wrong; you need to pass a callable and its arguments to callFromThread. So instead of reactor.callFromThread(foo(a, b)), you write reactor.callFromThread(foo, a, b). That means you should ultimately be using:: reactor.callFromThread(self.transport.write, data) -- Christopher Armstrong International Man of Twistery http://radix.twistedmatrix.com/ http://twistedmatrix.com/ http://canonical.com/