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

Gabriel Rossetti mailing_lists at evotex.ch
Thu Apr 17 10:22:20 EDT 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).

I have a producer sort of working thanks to this :


and this post :


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:

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 :


it does :

transport.registerProducer(self, 1)

thus starting the writing process and in the pull producer :


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

Thank you,

More information about the Twisted-Python mailing list