Wraps redis LuaLock
or Lock
object into RedisLockWrapper
Haochuan Guo
Branch: wooparadog/dogpile.cache:wraps-redis-lock
Branch: zzzeek/dogpile.cache:master
Declined
Declined pull request
`RedisLock` is compatible with the traditional "acquire()" signature
Closed by: Haochuan Guo·2014-07-30
Wraps redis lock, only exposing
acquire
andrelease
.Upper level functions should not call redis object directly. And catch
RedisError
while releasing a lock, because when trying to release a timeouted lock, redis will raise the following error.Traceback (most recent call last): File "/Users/WooParadog/Codes/github/dogpile.cache/tests/cache/test_redis_backend.py", line 54, in test_catch_any_exceptions_when_releasing_mutex mutex.release() File "/Users/WooParadog/.virtualenvs/dogpile/lib/python2.7/site-packages/redis/lock.py", line 104, in release self.do_release() File "/Users/WooParadog/.virtualenvs/dogpile/lib/python2.7/site-packages/redis/lock.py", line 236, in do_release raise LockError("Cannot release a lock that's no longer owned") LockError: Cannot release a lock that's no longer owned