[Twisted-Python] Question on push/pull producers inter-workings, was : "Is there a simple Producer/Consumer example or tutorial?"

Gabriel Rossetti mailing_lists at evotex.ch
Fri Apr 18 01:57:35 MDT 2008


Hello everyone,

I am re-posting these questions with a different title, since they have 
ventured away from the original question

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.

Oh, and also, since from what I see in the code the only difference with 
a push and pull producer is that the push producer is paused if the data 
being written/sent is very large (to let the reactor breath and process 
other things), if it isn't larger than the buffer it behaves like a pull 
producer, correct? If so, then why have both? Am I mixed up again?

Thank you,
Gabriel




More information about the Twisted-Python mailing list