Implement a Lock handler model #11

diranged opened this Issue Mar 12, 2013 · 2 comments

1 participant

Nextdoor member

Implement a mechanism for getting locks. Still TBD ... but something like:

lock = get_lock('/locks/mylock', wait=30)

Either returns True, or waits up to 30 seconds then returns False. Wait=0 would wait forever, Wait=None fast-fails.

@diranged diranged was assigned Mar 12, 2013
Nextdoor member

Patchset is undergoing review here:

Unfortunately it does not seem currently possible to have a "wait" timeout on our Lock acquire process. I will work with the Kazoo guys to see if there's something we can do to implement this.

Nextdoor member


When that issue is resolved, we'll be able to implement a non-blocking Lock acquire call with a wait timeout.

@nextdoor-gerrit nextdoor-gerrit pushed a commit that closed this issue Mar 26, 2013
@diranged diranged Closes #11: Create lock(), acquire_lock() and release_lock() methods.
This patch creates a nd_service_registry.Lock object that can be used in
two ways. In the first method, you can use the object in a 'with' block
-- explicitly acquiring the Lock only while your 'with' block is

The second model allows you to call acquire_lock() directly to lock a
path, but relies on you actively calling release_lock() (or your
connection expiring) before the lock will be free again.

At this time it is not possible to add a 'wait' timer in on the Locks
because of the way Kazoo is written. I'll work with the developers to
understand the behavior and see if we can add that model in later.

Change-Id: I4d361ee5a25236fb9fcb3168a310c9184312a961
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment