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
This commit is contained in:
Joshua Harlow 2015-04-21 17:02:16 -07:00
parent e4bbade4ef
commit 1664a04b3d
1 changed files with 2 additions and 1 deletions

View File

@ -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