[Twisted-Python] ReconnectingClientFactory & stopFactory

Andrew Bennetts andrew-twisted at puzzling.org
Sun Sep 1 22:46:49 EDT 2002


I think there might be a slight issue with the current client API.  If
the API is fine, the docs need improving! :)

Say you've subclasses ReconnectingClientFactory to connect to a database
in startFactory, disconnect in stopFactory.  If takes several connection
attempts, then multiple connections to the database will be opened and
closed (assuming this factory is only constructing one client, which is
the usual case, I suspect).

The problem appears to be that BaseConnector (in
twisted.internet.default) will always call stopFactory from
connectionLost/connectionFailed if it's state is 'disconnected', even if
it is between retries, because the connector knows nothing of the retry
logic in the Factory.

Does this sound like a geniune flaw, or am I misunderstanding something?
:)

I'm wondering if perhaps the solution would be to add a method (or
methods) to IConnector that let clientConnectionLost and
clientConnectionFailed signal to the connector that it isn't done using
that connector yet.

-Andrew.





More information about the Twisted-Python mailing list