Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock.acquire() interface change with 4.3.2 #2218

Closed
timhanus opened this issue Jun 6, 2022 · 1 comment · Fixed by #2254
Closed

Lock.acquire() interface change with 4.3.2 #2218

timhanus opened this issue Jun 6, 2022 · 1 comment · Fixed by #2254

Comments

@timhanus
Copy link

timhanus commented Jun 6, 2022

Version: 4.3.2 + 4.3.3

Platform: Python 3.7.15/Linux

Description:
I recently upgraded redis-py to the latest version(4.3.3) and began seeing TypeErrors during non-blocking acquisition of locks. It seems like this PR (#2137) introduced an interface change to the Lock.acquire() method.

Any version <= 4.3.1 allowed two ways to acquire a non-blocking lock.

  • lock.acquire(False)
  • lock.acquire(blocking=False)

In versions 4.3.2 and 4.3.3 the lock.acquire(False) gives TypeError: acquire() takes 1 positional argument but 2 were given and forces us to use the blocking= keyword arguments.

This library https://github.com/sqlalchemy/dogpile.cache/ (probably among others?) uses this redis Lock().acquire() and a threading.Lock().acquire() interchangeably.
https://docs.python.org/3/library/threading.html#threading.Lock.acquire
https://github.com/sqlalchemy/dogpile.cache/blob/main/dogpile/lock.py#L126

To maybe belabor the point. This script runs under 4.3.1 but not under 4.3.2

import redis
client = redis.Redis()
lock = client.lock('lockName')
if lock.acquire(False):
    print("lock acquired!")
    lock.release()

To me, this seems like introducing a breaking change in a patch release which caught me off guard.

@timhanus
Copy link
Author

timhanus commented Jun 6, 2022

After submit, also referenced here: #2209 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant