diff options
author | Anton Skornyakov <anskor@yandex-team.ru> | 2017-04-20 18:25:46 +0300 |
---|---|---|
committer | Anton Skornyakov <anskor@yandex-team.ru> | 2017-04-20 18:25:46 +0300 |
commit | a67432256ba3aebceb3fe12c70584f7b8a440b7a (patch) | |
tree | 2e6b18180183b45eebf6d40dd42d0854e27e4153 | |
parent | 4df0011afce8c4412442c27517f2529a1258220e (diff) | |
download | kazoo-a67432256ba3aebceb3fe12c70584f7b8a440b7a.tar.gz |
fix deadlock in nonblocking semaphore acquiring, do inner lock release for every lock acquiring attempt
-rw-r--r-- | kazoo/recipe/lock.py | 6 |
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() |