[Twisted-Python] Is there a simple Producer/Consumer example or tutorial?

Gabriel Rossetti mailing_lists at evotex.ch
Thu Apr 17 08:22:20 MDT 2008


Drew Smathers wrote:
> On Thu, Apr 17, 2008 at 3:25 AM, Gabriel Rossetti
> <mailing_lists at evotex.ch> wrote:
>   
>> Hello all,
>>
>>  I was wondering if there is a simple example or a tutorial for the
>> Producer-Consumer stuff in twisted?
>>
>>     
>
> The only document I'm aware of:
> http://twistedmatrix.com/projects/core/documentation/howto/producers.html
>
> The above explains the interfaces and how to use them, but lacks any examples.
>
> Btw ... the last link on the page is broken
> (http://twistedmatrix.com/projects/core/documentation/howto/twisted.protocols.basic.FileSender).
>
>
>   
Thanks,

I have a producer sort of working thanks to this :

http://itamarst.org/writings/OSCON03/twisted_internet-0.html

and this post :

http://twistedmatrix.com/pipermail/twisted-python/2007-March/014943.html

I have a question though, I was looking at the way all this works by 
using a debugger, and I noticed that in twisted.internet.abstract.py in 
registerProducer() there is the following :

if not streaming:
    producer.resumeProducing()

Why is this done only for the pull producer? Shouldn't it also be called 
for the push producer since to have the data sent one has to call either 
self.transport.write() or resumeProducing() anyways? If you look at :

http://itamarst.org/writings/OSCON03/twisted_internet-112.html

it does :

transport.registerProducer(self, 1)
        self.produce()

thus starting the writing process and in the pull producer :

http://itamarst.org/writings/OSCON03/twisted_internet-111.html

it doesn't need to start the writing process explicitly since it's 
started when the producer is registered.

Thank you,
Gabriel








More information about the Twisted-Python mailing list