bzrlib should provide context managers for locking

Bug #522195 reported by Henning Eggers on 2010-02-15
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

In a recent Launchpad branch I implemented this:

class ReadLockTree(object):
    """Context manager to claim a read lock on a bzr tree."""

    def __init__(self, tree):
        self.tree = tree

    def __enter__(self):

    def __exit__(self, exc_type, exc_val, exc_tb):
        return False

And used it like this:

  with ReadLockTree(tree):

It would be great if it was generally integrated into bzrlib so that it can be used like this:

  with lockable_object.read_lock():

Same for write locks.

Related branches

 importance wishlist
 status confirmed

Thanks; if you'd like this integrated, I suggest writing some tests for
it (python 2.4 compatible!) and proposing a merge.

It could live in the decorators module or the cleanup module, or even a
new one.


Changed in bzr:
importance: Undecided → Wishlist
status: New → Confirmed
Martin Pool (mbp) wrote :

Thanks for working on this, Henning. Please propose a merge when you're ready and just ask if you want help.

Changed in bzr:
status: Confirmed → In Progress
tags: added: locking
Jelmer Vernooij (jelmer) on 2011-06-19
Changed in bzr:
status: In Progress → Confirmed
Jelmer Vernooij (jelmer) on 2017-11-09
tags: added: check-for-breezy
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers