Do you need to close a branch? (if so how)
Vincent Ladeuil
v.ladeuil+lp at free.fr
Fri Feb 27 10:14:07 GMT 2009
>>>>> "robert" == Robert Collins <robertc at robertcollins.net> writes:
robert> On Thu, 2009-02-26 at 18:48 +1300, Michael Hudson wrote:
>>
>>
>> We had this problem with codebrowse (which access branches over HTTP)
>> and eventually arrived at the same solution as you. I think there
>> should probably be a Transport.close() method.
robert> This definitely should not be needed.
robert> If:
robert> foo = get_transport('foo')
robert> del foo
robert> leaves sockets open, there is a bug in bzr
Or in socket.py or in urllib2.py or _socketmodule.c or in the way
we use them (our bug) or in the way they are designed (not our
bug) ...
Even after several deep hacking sessions on the subject, I'm not
sure about that because there are two things fighting to hide the
problem in most of the cases: one is the gc (which I suspect
can't do its job properly in some cases) and the other is the
timeout on the socket (on server *or* client side) which ends up
in the socket being closed as a side-effect.
I smell a circular reference too (like John) but have yet to find
it... (but see http://bugs.python.org/issue3066).
On the other hand explicitly closing the socket (directly or via
the transport or via the branch, each delegating in turn) sounds
like something that will fix the socket leak.
I've thought about doing that in the test suite (by adding a
cleanup each time we create a transport) if only to get rid of
the leaking tests...
I don't propose to make it happen automatically though, but at
least we could make it possible to call transport.close()
explicitly when needed and we now have two such cases: the test
suite and the branch polling scripts.
Vincent
More information about the bazaar
mailing list