[Twisted-Python] Basic factory question

Jean-Paul Calderone exarkun at divmod.com
Mon Apr 13 14:32:11 EDT 2009

On Mon, 13 Apr 2009 11:25:12 -0700, Ted Pederson <ted.pederson at gmail.com> wrote:
>Coming from C++ to python/twisted. Looking at samples, created a simple
>server and want to create a tester file that will create many clients to
>connect to and exercise my server. All very nice and easy and like this a
>lot so far.
>The one thing that looks strange to me is that the samples instantiate a
>ClientFactory to then connect to the server via reactor.connectTCP().
>I copied this pattern, worried that a factory would be created for every one
>of my clients, and this is indeed what happened. Isn't the point of a
>factory to generate all of the clients? I'd like to keep some aggregate info
>in 1 factory, and have the factory contain the dbpools, etc.. How to do

You can pass a single ClientFactory instance to connectTCP multiple times,
if that's what you want to do.  If the factory is where you keep various
other resources for the client connections to use, then this makes perfect


More information about the Twisted-Python mailing list