Jump to solution
Verify

The Fix

pip install redis==7.1.0

Based on closed redis/redis-py issue #3459 · PR/commit linked

Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.

Jump to Verify Open PR/Commit
@@ -1378,6 +1378,7 @@ def __init__( # release the lock. self._fork_lock = threading.Lock() + self._lock = threading.Lock() self.reset()
repro.py
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, }, ... } }
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
Option A — Upgrade to fixed release\npip install redis==7.1.0\nWhen NOT to use: Do not use this fix if the application relies on the previous behavior of the connection pool.\n\n

Why This Fix Works in Production

  • Trigger: 'BlockingConnectionPool' object has no attribute '_lock'
  • Mechanism: Moved self._lock initialization to the Pool constructor to ensure it is set correctly in BlockingConnectionPool.
  • Why the fix works: Moved self._lock initialization to the Pool constructor to ensure it is set correctly in BlockingConnectionPool. (first fixed release: 7.1.0).
Production impact:
  • If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.

Why This Breaks in Prod

  • Shows up under Python 3.11 in real deployments (not just unit tests).
  • Surfaces as: File "/.venv/lib/python3.11/site-packages/django_redis/client/default.py", line 258, in get\n value = client.get(key)\n ^^^^^^^^^^^^^^^\n File…

Proof / Evidence

  • GitHub issue: #3459
  • Fix PR: https://github.com/redis/redis-py/pull/3473
  • First fixed release: 7.1.0
  • Reproduced locally: No (not executed)
  • Last verified: 2026-02-08
  • Confidence: 0.95
  • Did this fix it?: Yes (upstream fix exists)
  • Own content ratio: 0.40

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“**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: StackTrace is It seems that in BlockingConnectionPool, self._lock is not set in the init m”
Issue thread · issue description · source

Failure Signature (Search String)

  • 'BlockingConnectionPool' object has no attribute '_lock'

Error Message

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

Minimal Reproduction

repro.py
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, }, ... } }

Environment

  • Python: 3.11

What Broke

Application raises an AttributeError when attempting to use the connection pool.

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

pip install redis==7.1.0

When NOT to use: Do not use this fix if the application relies on the previous behavior of the connection pool.

Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.

Fix reference: https://github.com/redis/redis-py/pull/3473

First fixed release: 7.1.0

Last verified: 2026-02-08. Validate in your environment.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • Do not use this fix if the application relies on the previous behavior of the connection pool.

Verify Fix

verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.

Did This Fix Work in Your Case?

Quick signal helps us prioritize which fixes to verify and improve.

Prevention

  • Add a stress test that runs high-concurrency workloads and fails on thread dumps / blocked locks.
  • Enable watchdog dumps in prod (faulthandler, thread dump endpoint) to capture deadlocks quickly.
  • Track RSS + object counts after deployments; alert on monotonic growth and GC pressure.
  • Add a long-running test that repeats the failing call path and asserts stable memory.

Version Compatibility Table

VersionStatus
7.1.0 Fixed

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.