From 1664a04b3d11c06017566809fec7b5d94dae52db Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Tue, 21 Apr 2015 17:02:16 -0700 Subject: [PATCH] Avoid using a thread local token storage When one thread is running the coordinator heartbeat() periodically and another is using the lock(s) it should be possible to correctly make this happen/work without errors of the type of: AttributeError: '_thread._local' object has no attribute 'token' This happens because the coordinator heartbeat() method calls into each current lock(s) heartbeat() method (which then extends the lock via the locks extend() method); when this is using thread local storage this fails with the above error. So to avoid this explicitly disallow using thread local token storage by ensuring we pass in the right param to the underlying redis lock. Change-Id: I8e5592813577c3cf1cf9a67d0005d1e0ef180fca --- tooz/drivers/redis.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tooz/drivers/redis.py b/tooz/drivers/redis.py index 1a2ba0f8..27bcc8bd 100644 --- a/tooz/drivers/redis.py +++ b/tooz/drivers/redis.py @@ -99,7 +99,8 @@ class RedisLock(locking.Lock): # # When that gets fixed (and detects the servers capabilities better # we can likely turn this back on to being smart). - self._lock = redis_locks.Lock(client, self._name, timeout=timeout) + self._lock = redis_locks.Lock(client, self._name, + timeout=timeout, thread_local=False) self._coord = coord self._acquired = False