feat: adds option not to raise exception when leaving context manager after lock expiration by julianolm · Pull Request #3531 · redis/redis-py (original) (raw)
Fixes: #3532
Pull Request check-list
Please make sure to review and check all of these items:
- Do tests and lints pass with this change?
- Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
- Is the new or changed code fully tested?
- Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
- Is there an example added to the examples folder (if applicable)?
- Was the change added to CHANGES file?
NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.
Description of change
I was having trouble using async locks with the context manager because it was failing when exiting the context manager after timeout had expired (even if my code executed successfully).
I would really like not to raise a LockNotOwnedError
in the exit of the context manager (if I try to release a lock and it was already "released" then great!).
I understand just changing the behavior would be critical, so I added an option to just behave this way when desired instead.
Issue: #3532