Merge pull request #430 from anskornyakov/hotfix/semaphore-deadlock

fix deadlock in nonblocking semaphore acquiring
This commit is contained in:
Ben Bangert 2017-05-31 15:03:02 -07:00 committed by GitHub
commit 3cc86ac06e

View File

@ -557,10 +557,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()