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

'BlockingConnectionPool' object has no attribute '_lock' #3459

Open
WenminZhao opened this issue Dec 19, 2024 · 0 comments
Open

'BlockingConnectionPool' object has no attribute '_lock' #3459

WenminZhao opened this issue Dec 19, 2024 · 0 comments

Comments

@WenminZhao
Copy link

Version: redis-py 5.2.1

Platform: MacOS 15.1.1 (24B91)

Description: I have this issue when using django and redis-py.

CACHE settings are:

CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "OPTIONS": {
            "CONNECTION_POOL_CLASS": "redis.BlockingConnectionPool",
            "CONNECTION_POOL_KWARGS": {
                "max_connections": 50,
                "timeout": 20,
                "protocol": 3,
                "cache_config": CacheConfig(),
            },
            "PICKLE_VERSION": -1,
        },
       ...
     }
}

StackTrace is

 File "/.venv/lib/python3.11/site-packages/django_redis/client/default.py", line 258, in get
    value = client.get(key)
            ^^^^^^^^^^^^^^^
  File "/.venv/lib/python3.11/site-packages/redis/commands/core.py", line 1822, in get
    return self.execute_command("GET", name, keys=[name])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.venv/lib/python3.11/site-packages/redis/client.py", line 559, in execute_command
    return self._execute_command(*args, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.venv/lib/python3.11/site-packages/redis/client.py", line 565, in _execute_command
    conn = self.connection or pool.get_connection(command_name, **options)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.venv/lib/python3.11/site-packages/redis/connection.py", line 1634, in get_connection
    connection = self.make_connection()
                 ^^^^^^^^^^^^^^^^^^^^^^
  File "/.venv/lib/python3.11/site-packages/redis/connection.py", line 1599, in make_connection
    self.connection_class(**self.connection_kwargs), self.cache, self._lock
                                                                 ^^^^^^^^^^

It seems that in BlockingConnectionPool, self._lock is not set in the init method. The base class ConnectionPool set it in the reset method: https://github.com/redis/redis-py/blob/v5.2.1/redis/connection.py#L1346, while BlockingConnectionPool doesn't: https://github.com/redis/redis-py/blob/v5.2.1/redis/connection.py#L1571

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

No branches or pull requests

1 participant