diff options
author | Andy McCurdy <andy@andymccurdy.com> | 2010-06-15 09:55:11 -0700 |
---|---|---|
committer | Andy McCurdy <andy@andymccurdy.com> | 2010-06-15 09:55:11 -0700 |
commit | 90668b6e104f6c41babb4d64143ade4d81a47263 (patch) | |
tree | 6baa80916f5ac7cd80b9fa6e4b56e879d08dac31 /redis/client.py | |
parent | 41840883f673171e05df352eadeac41b28e10ba7 (diff) | |
download | redis-py-90668b6e104f6c41babb4d64143ade4d81a47263.tar.gz |
configurable sleep duration
Diffstat (limited to 'redis/client.py')
-rw-r--r-- | redis/client.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/redis/client.py b/redis/client.py index 17ffb7c..4f178a1 100644 --- a/redis/client.py +++ b/redis/client.py @@ -1315,7 +1315,7 @@ class Lock(object): self.name = name self.acquired_until = None - def acquire(self, blocking=True, timeout=None): + def acquire(self, blocking=True, timeout=None, sleep=0.1): """ Use Redis to hold a shared, distributed lock named ``name``. Returns True once the lock is acquired. @@ -1325,6 +1325,9 @@ class Lock(object): ``timeout`` indicates the maxium lifetime of the lock. If None, lock forever. + + ``sleep`` indicates the the amount of time to sleep during each loop + while attempting to acquire the lock when ``blocking``=True Note: If using ``timeout``, you should make sure all the hosts that are running clients are within the same timezone and are using @@ -1351,7 +1354,7 @@ class Lock(object): return True if not blocking: return False - time.sleep(0.1) + time.sleep(sleep) def release(self): "Releases the already acquired lock" |