Do you need to close a branch? (if so how)
Michael Hudson
michael.hudson at canonical.com
Thu Feb 26 21:27:28 GMT 2009
John Arbash Meinel wrote:
> Robert Collins wrote:
>> 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.
>> This definitely should not be needed.
>
>> If:
>> foo = get_transport('foo')
>> del foo
>
>> leaves sockets open, there is a bug in bzr - file the bug report and
>> marked it confirmed and high.
Well, maybe I have an unusual opinion here, but I think that relying on
automatic memory management to manage resources other than memory is
inviting trouble.
> I think I remember something about cyclic references for Branch objects
> causing problems. I'm not sure what exact objects were triggering it,
> but we do occasionally get cycles in our objects, and we haven't ever
> spent much time to track them down (the don't matter much for the bzr
> commandline client).
>
> So you might try:
> import gc
> gc.collect()
I think I tried that and it didn't help. In fact, you can prove this to
yourself by running:
>>> while 1:
... b = bzrlib.branch.Branch.open("http://localhost:8080/trunk")
... del b
... gc.collect()
in an interactive interpreter and watching netstat in another terminal
(it blows up after a while).
In fact, we seem to be accumulating socket._fileobjects in gc.garbage,
which would explain things...
Cheers,
mwh
Cheers,
mwh
More information about the bazaar
mailing list