Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Feature: let lock.extend ignore the remaining ttl. #1303
Pull Request check-list
Please make sure to review and check all of these items:
NOTE: these things are not required to open a PR and can be done
Description of change
Lock.extend now has a new option: keep_remaining, default to False, which is identical with the old Lock.extend; When set to True, extend will set lock's ttl exactly the additional time.
A common use case would be, let's see we have 4 process and just want one to keep running, others standby. When running process is broken or offline, one of the other 3 can takeover. In order to to that, we use a lock to make sure only one prcess is running, and this process extends lock every 8 seconds before a timeout(10 seconds).
If without the new option
Currently there are many workarounds (see #629 for example), but I think it would be better for redis-py to support this.
@@ Coverage Diff @@ ## master #1303 +/- ## ========================================== + Coverage 92.81% 92.82% +0.01% ========================================== Files 19 19 Lines 6526 6536 +10 ========================================== + Hits 6057 6067 +10 Misses 469 469
andymccurdy left a comment
Let's go with
It seems far easier/less code to simply pass the