summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Skornyakov <anskor@yandex-team.ru>2017-04-20 18:25:46 +0300
committerAnton Skornyakov <anskor@yandex-team.ru>2017-04-20 18:25:46 +0300
commita67432256ba3aebceb3fe12c70584f7b8a440b7a (patch)
tree2e6b18180183b45eebf6d40dd42d0854e27e4153
parent4df0011afce8c4412442c27517f2529a1258220e (diff)
downloadkazoo-a67432256ba3aebceb3fe12c70584f7b8a440b7a.tar.gz
fix deadlock in nonblocking semaphore acquiring, do inner lock release for every lock acquiring attempt
-rw-r--r--kazoo/recipe/lock.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/kazoo/recipe/lock.py b/kazoo/recipe/lock.py
index d351539..59cd146 100644
--- a/kazoo/recipe/lock.py
+++ b/kazoo/recipe/lock.py
@@ -472,10 +472,10 @@ class Semaphore(object):
w = _Watch(duration=timeout)
w.start()
lock = self.client.Lock(self.lock_path, self.data)
- gotten = lock.acquire(blocking=blocking, timeout=w.leftover())
- if not gotten:
- return False
try:
+ gotten = lock.acquire(blocking=blocking, timeout=w.leftover())
+ if not gotten:
+ return False
while True:
self.wake_event.clear()