Do you need to close a branch? (if so how)
James Westby
jw+debian at jameswestby.net
Tue Feb 24 23:11:09 GMT 2009
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
More information about the bazaar
mailing list