[Twisted-Python] iConnector factory not what expected
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
>> 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:
> 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?
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
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