[Twisted-Python] IPushProducer - medium volume streaming

Phil Mayers p.mayers at imperial.ac.uk
Mon Oct 29 10:43:57 EDT 2007

On Mon, 2007-10-29 at 09:21 -0400, Rutt, Benjamin wrote:
> Thanks.  Now using callInThread to launch a long-running function on the
> server and callFromThread from said function to write results to the
> client.
> I'm still puzzled how exactly
> 'reactor.callFromThread(self.transport.writeSomeData(...))' gets routed

I presume you mean:

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

Note the subtle difference

> to the right client when called from my function.  How does twisted know

The "transport" object is a bound connection and contains the address of
the endpoint (if you're using TCP that is)

> 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?
> -----Original Message-----
> From: twisted-python-bounces at twistedmatrix.com
> [mailto:twisted-python-bounces at twistedmatrix.com] On Behalf Of
> Christopher Armstrong
> Sent: Sunday, October 28, 2007 12:11 PM
> To: Twisted general discussion
> Subject: Re: [Twisted-Python] IPushProducer - medium volume streaming
> On 10/28/07, Rutt, Benjamin <Benjamin.Rutt at gs.com> wrote:
> > It's a long-running streaming flow so there will be millions of
> results
> > to send to the client.  You're saying I call deferToThread millions of
> > times?
> No, I was just correcting your description of the way that
> deferToThread is used.
> If you don't want to use deferToThread, then you should probably use a
> combination of reactor.callInThread and reactor.callFromThread.

More information about the Twisted-Python mailing list