[Twisted-Python] IPushProducer - medium volume streaming

Rutt, Benjamin Benjamin.Rutt at gs.com
Mon Oct 29 11:10:15 MDT 2007


Thanks Chris and Phil.  My mistake for writing

'reactor.callFromThread(self.transport.writeSomeData(...))'

not

'reactor.callFromThread(self.transport.writeSomeData, ...)' 

the latter which I'm actually using.

Also I fixed to use write() not writeSomeData(), thanks.

Regarding state, I take it each new client connection to my server
results in a new instance of my LineReceiver subclass.  So therefore the
self.transport object contains the TCP socket fd in there somewhere -
makes sense, thanks.

-----Original Message-----
From: twisted-python-bounces at twistedmatrix.com
[mailto:twisted-python-bounces at twistedmatrix.com] On Behalf Of
Christopher Armstrong
Sent: Monday, October 29, 2007 10:57 AM
To: Twisted general discussion
Subject: Re: [Twisted-Python] IPushProducer - medium volume streaming

On 10/29/07, Rutt, Benjamin <Benjamin.Rutt at 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/

_______________________________________________
Twisted-Python mailing list
Twisted-Python at twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python




More information about the Twisted-Python mailing list