transports and connections
Andrew Bennetts
andrew at canonical.com
Thu Aug 31 04:07:26 BST 2006
John Arbash Meinel wrote:
> Robert Collins wrote:
[...]
> > get_transport() as /not/ connecting to the server, but rather the
> > returned transport connecting when the first operation is called on it.
[...]
>
> I agree, but I'm not sure how it will affect transports that want to
> share a connection. So if I connect to the same ssh machine 2 times,
> currently bzr will share the sftp connection.
>
> I realize we want to modify how caching/sharing works anyway. But I
> wouldn't want lazy evaluation to start causing double connects.
I agree, but you can have both.
E.g. for the SFTPTransport, there's currently an _sftp attribute that's the
object of the actual connection. Cloning makes sure that object is shared.
All you need to change about that is that the object in _sftp would have to have
the lazy connection magic -- not the transport. You could write a test case
like:
t = get_transport()
t2 = t.clone('foo')
self.assertNotConnected(t)
self.assertNotConnected(t2)
t2.has('bar')
self.assertConnected(t)
self.assertConnected(t2)
I share the underlying connection object like this already in for the
SmartTransport in my smart server branch.
-Andrew.
More information about the bazaar
mailing list