On lock removal validate that they key was actually deleted

Instead of assuming the lock was released (when it might have
not been) be more reliable and return whether it really was
or was not by validating the reply.

Change-Id: I70b2e1946d5101c7fbbf4ed9f15007bb98e92581
This commit is contained in:
Joshua Harlow 2014-09-16 16:48:18 -07:00 committed by Joshua Harlow
parent 90792db9d4
commit fab18f8c80
1 changed files with 5 additions and 2 deletions

View File

@ -67,8 +67,11 @@ class MemcachedLock(locking.Lock):
raise Retry
def release(self):
self.coord._acquired_locks.remove(self)
return bool(self.coord.client.delete(self.name))
if self.coord.client.delete(self.name, noreply=False):
self.coord._acquired_locks.remove(self)
return True
else:
return False
def heartbeat(self):
"""Keep the lock alive."""