[Twisted-Python] Simultaneous Blocking Operations and Twisted

Matthew Glubb matt at zgroupplc.com
Fri Mar 30 06:11:32 MDT 2007


Hi Jean-Paul,

Thanks for your response.

On 30 Mar 2007, at 12:18, Jean-Paul Calderone wrote:

> The conventional way to do this would be to write a function which  
> sets up
> the listening port and returns a Deferred which will eventually be  
> called
> back with the result (presumably the data which some client will  
> eventually
> send to it).  Then, using reactor.callLater, set up a timed call  
> which will
> tear down the listening port after the timeout has expired and  
> errback the
> Deferred to indicate no data arrived within the timeout period.

Yes, that's the way I have started doing it, basing it on what I have  
seen in various modules and sub-classing ClientFactory and  
LineReceiver. I am a little confused as to how, when the Deferred is  
returned from the factory, the callbacks that are defined are  
connected to the originating client request. I assume that all I have  
to do is to write the response to the client from the callback and  
that's it.

I guess what I am asking is, if an HTTP request (serviced using  
twisted.web.soap and twistd) starts an asynchronous operation, how  
does it know that it should wait for an event from the operation  
before completing its response.

>> As an aside, is it possible to compile platform specific python  
>> applications as small binaries? Or does the interpreter (is it   
>> required?) mean the memory consumption is prohibitive?
>
> Generally the only thing that's possible is to wrap up the whole  
> application
> with the whole interpreter and some subset of the standard library  
> in an
> executable.  This doesn't sound much like what you're after, though.

Yes, that's what I thought, although I wondered whether someone might  
have written a wonderful tool :)

Thanks again for your time,

Matt




More information about the Twisted-Python mailing list