diff options
author | Andy McCurdy <andy@andymccurdy.com> | 2014-06-01 08:12:47 -0700 |
---|---|---|
committer | Andy McCurdy <andy@andymccurdy.com> | 2014-06-01 08:14:27 -0700 |
commit | b36ab87d22dc9b4f0109d17f6f3c7740bb48a7fe (patch) | |
tree | 1f53a914aa23a569da2b39f93e7bdf40f02ed2a2 /redis/client.py | |
parent | be6e501d046c9fb7ef86a47ec3b276a22997e900 (diff) | |
download | redis-py-b36ab87d22dc9b4f0109d17f6f3c7740bb48a7fe.tar.gz |
updated Lock class:
* now uses unique string tokens to claim lock ownership
* added extend() method to extend the timeout on an already acquired lock
Diffstat (limited to 'redis/client.py')
-rwxr-xr-x | redis/client.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/redis/client.py b/redis/client.py index efce1d8..502549a 100755 --- a/redis/client.py +++ b/redis/client.py @@ -476,7 +476,7 @@ class StrictRedis(object): except WatchError: continue - def lock(self, name, timeout=None, sleep=0.1): + def lock(self, name, timeout=None, sleep=0.1, blocking_timeout=None): """ Return a new Lock object using key ``name`` that mimics the behavior of threading.Lock. @@ -487,8 +487,14 @@ class StrictRedis(object): ``sleep`` indicates the amount of time to sleep per loop iteration when the lock is in blocking mode and another client is currently holding the lock. + + ``blocking_timeout`` indicates the maximum amount of time in seconds to + spend trying to acquire the lock. A value of ``None`` indicates + continue trying forever. ``blocking_timeout`` can be specified as a + float or integer, both representing the number of seconds to wait. """ - return Lock(self, name, timeout=timeout, sleep=sleep) + return Lock(self, name, timeout=timeout, sleep=sleep, + blocking_timeout=blocking_timeout) def pubsub(self, **kwargs): """ |