diff options
author | Andy McCurdy <andy@andymccurdy.com> | 2018-11-15 12:05:57 -0800 |
---|---|---|
committer | Andy McCurdy <andy@andymccurdy.com> | 2018-11-15 12:05:57 -0800 |
commit | 2239c6962ad5f86395c142ce8f352650b11cabb5 (patch) | |
tree | 1bb243dfbb2b56b4ab5cf15b436a2413d02bd538 /redis/lock.py | |
parent | 40c4633e08d3f14d0abbaa22592e8c4d2f859c8b (diff) | |
download | redis-py-2239c6962ad5f86395c142ce8f352650b11cabb5.tar.gz |
Update .locked() to indicate if lock has been acquired by any proceses
This make just like threading.Lock objects do.
Fixed #1007
Diffstat (limited to 'redis/lock.py')
-rw-r--r-- | redis/lock.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/redis/lock.py b/redis/lock.py index 43c0813..c6fd01d 100644 --- a/redis/lock.py +++ b/redis/lock.py @@ -173,8 +173,10 @@ class Lock(object): return False def locked(self): - token = self.local.token - return token and self.redis.get(self.name) == token or False + """ + Returns True if this key is locked by any process, otherwise False. + """ + return self.redis.get(self.name) is not None def release(self): "Releases the already acquired lock" |