Do you need to close a branch? (if so how)
Nicholas Allen
nick.allen at onlinehome.de
Tue Feb 24 23:23:31 GMT 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Thanks for the help - I will try that. But that still doesn't explain
why I run out of sockets...
Nick
James Westby wrote:
> On Tue, 2009-02-24 at 22:46 +0100, Nicholas Allen wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Hi,
>>
>> In my bzr-email-notifier tool I do the following:
>>
>> try:
>> parent_location = branch.get_parent()
>>
>> if not parent_location is None:
>> parent_branch = Branch.open(parent_location)
>> branch.pull(parent_branch)
>> except BzrError, e:
>> print >>sys.stderr, \
>> 'Could not pull from parent for branch %s:
>> %s' % (branch_emailer.path, e)
>>
>>
>> Do I need to do something to close the parent branch after I am finished
>> with it? I can't find a close method on Branch. I notice that after a
>> while I run out of sockets on my server so I guess open is keeping a
>> socket open even after the parent branch (which is remote) is no longer
>> needed.
>
> You don't need to close anything, but you should be taking out locks,
> and they require unlocking.
>
> branch.lock_write()
> try:
> parent_branch = Branch.open(parent_location)
> parent_branch.lock_read()
> try:
> branch.pull(parent_branch)
> finally:
> parent_branch.unlock()
> finally:
> branch.unlock()
>
> Thanks,
>
> James
>
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkmkgXAACgkQ1+i51gqqEGm+9wCePgV9HJvErLQufm/HZiCeE9+p
XEkAoIH5nQx4Ue3aoyvumymAwkvukr71
=kvgJ
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list