[Twisted-Python] iConnector factory not what expected

Martin martin at webscio.net
Fri Jun 15 04:50:17 EDT 2012

On 15/06/12 01:40, exarkun at twistedmatrix.com wrote:
> On 14 Jun, 03:34 pm, martin at webscio.net wrote:
>> Hi again,
>> I've a bit of code that does the following:
>> f = MyReconnectingClientFactory()
>> iConn = reactor.connectSSL(url, port, f, ssl.ClientContextFactory())
>> now I would expect that iConn.factory would be my f, but as it turns
>> out
>> it's an instance of some TLSMemoryBIOFactory.. Why is that so?
>> After some digging, I was able to find f under
>> iConn.transport.protocol.wrappedProtocol.factory.. I'm happy to use
>> that, but it just sounds a bit weird to me.. or is this normal?
> There is no "factory" attribute on the `IConnector` interface at all:
> http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IConnector.html
> Neither is there a "transport" attribute, nor do any of the transport
> interfaces have a "protocol" attribute.
> All this means that Twisted isn't promising you anything about the
> meaning or existence of any of these attributes.
> So, why don't you just use `f` instead?
> Jean-Paul
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
I can't use f because I'm saving the IConnector object for later, so 
that I can disconnect it when needed. I'm not sure if saving the f 
object would have any effect, since doing anything to that after the 
connection was created will surely have no effect, or?

In general, I can do iConn.disconnect(), but this being a 
ReconnectingClientFactory, it attempts to reconnect straight away.. 
That's why I was looking to get the factory object somehow, so that I 
could call stopTrying() on it first. If there's a better approach to 
this, please let me know :)


More information about the Twisted-Python mailing list