Slide 53
Slide 53 text
@nduthoit 53
1 class NonLockingRedisLock(RedisLock):
2 def __init__(self, key, expires, timeout, client):
3 self.locked = False
4 timeout = 0 # no timeout
5 super(NonLockingRedisLock, self).__init__(key, expires,
6 timeout, client)
7
8 def acquire(self):
9 try:
10 super(NonLockingRedisLock, self).acquire()
11 self.locked = True
12 except LockTimeout:
13 self.locked = False
14 statsd.incr('interfaces.lock.timeout')
15 logger.warning("LockTimeout", exc_info=full_exc_info())
16 except RedisError:
17 self.enabled = False
18 logger.warning("Lock.acquire RedisError",
19 exc_info=full_exc_info())
20 statsd.incr('interfaces.lock.RedisError')
21 ...
measure!
pylock
Thursday, 5 September, 13