[Twisted-Python] Producers and Consumers

Andrew Bennetts andrew-twisted at puzzling.org
Wed Jan 15 09:23:22 EST 2003

On Thu, Jan 16, 2003 at 01:08:13AM +1100, Andrew Bennetts wrote:
> Now, I could do FTPClient.store similarly to how I do FTPClient.retrieve,
> i.e.
>     def store(self, path, protocol):
>         """ ...
>         @param path: The path to store data to.
>         @param protocol: A L{Protocol} instance that will write the data
>             to be stored upon a call to C{connectionMade}, and will call
>             C{self.transport.loseConnection()} when done.
>         """
>         # ...
> But everyone assures me that requiring protocol instances as parameters is a
> bad way to do things, and my gut feeling agrees -- I just don't feel
> comfortable with asking Twisted users to instantiate a Protocol without
> involving a Factory.

I forgot to mention the other problem with this... I suspect the performance

class Uploader:
    def connectionMade(self):

would be suboptimal, to say the least ;)

In fact, I'm pretty certain the right way to do this is to use a producer,
just like twisted.web :)


More information about the Twisted-Python mailing list