Merge "LOG a warning if the heartbeat can not be validated"

This commit is contained in:
Jenkins 2014-09-17 09:19:50 +00:00 committed by Gerrit Code Review
commit 07ec935900
1 changed files with 10 additions and 2 deletions

View File

@ -17,6 +17,7 @@
# under the License.
import collections
import logging
import msgpack
import pymemcache.client
@ -27,6 +28,9 @@ from tooz import coordination
from tooz import locking
LOG = logging.getLogger(__name__)
class Retry(Exception):
"""Exception raised if we need to retry."""
@ -68,8 +72,12 @@ class MemcachedLock(locking.Lock):
def heartbeat(self):
"""Keep the lock alive."""
self.coord.client.touch(self.name,
expire=self.timeout)
poked = self.coord.client.touch(self.name,
expire=self.timeout,
noreply=False)
if not poked:
LOG.warn("Unable to heartbeat by updating key '%s' with extended"
" expiry of %s seconds", self.name, self.timeout)
def get_owner(self):
return self.coord.client.get(self.name)