Jump to solution
Verify

The Fix

pip install redis==7.1.0

Based on closed redis/redis-py issue #2811 · 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
@@ -1379,7 +1379,7 @@ def load_scripts(self): """ Close the connection, raise an exception if we were watching, - and raise an exception if retry_on_timeout is not set, + and raise an exception if TimeoutError is not part of retry_on_error, or the error is not a TimeoutError
repro.py
>> import redis >> redis_cli = redis.Redis(socket_timeout=10, retry_on_timeout=True) >> pubsub = redis_cli.pubsub() >> pubsub.subscribe("channel") >> for item in pubsub.listen(): ... print(item["type"]) ... subscribe Traceback (most recent call last): File "/venv_test/lib/python3.7/site-packages/redis/connection.py", line 210, in _read_from_socket data = self._sock.recv(socket_read_size) socket.timeout: timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/venv_test/lib/python3.7/site-packages/redis/client.py", line 1664, in listen response = self.handle_message(self.parse_response(block=True)) File "/venv_test/lib/python3.7/site-packages/redis/client.py", line 1542, in parse_response response = self._execute(conn, try_read) File "/venv_test/lib/python3.7/site-packages/redis/client.py", line 1520, in _execute lambda error: self._disconnect_raise_connect(conn, error), File "/venv_test/lib/python3.7/site-packages/redis/retry.py", line 49, in call_with_retry fail(error) File "/venv_test/lib/python3.7/site-packages/redis/client.py", line 1520, in <lambda> lambda error: self._disconnect_raise_connect(conn, error), File "/venv_test/lib/python3.7/site-packages/redis/client.py", line 1507, in _disconnect_raise_connect raise error File "/venv_test/lib/python3.7/site-packages/redis/retry.py", line 46, in call_with_retry return do() File "/venv_test/lib/python3.7/site-packages/redis/client.py", line 1519, in <lambda> lambda: command(*args, **kwargs), File "/venv_test/lib/python3.7/site-packages/redis/client.py", line 1540, in try_read return conn.read_response(disconnect_on_error=False) File "/venv_test/lib/python3.7/site-packages/redis/connection.py", line 874, in read_response response = self._parser.read_response(disable_decoding=disable_decoding) File "/venv_test/lib/python3.7/site-packages/redis/connection.py", line 347, in read_response result = self._read_response(disable_decoding=disable_decoding) File "/venv_test/lib/python3.7/site-packages/redis/connection.py", line 357, in _read_response raw = self._buffer.readline() File "/venv_test/lib/python3.7/site-packages/redis/connection.py", line 260, in readline self._read_from_socket() File "/venv_test/lib/python3.7/site-packages/redis/connection.py", line 223, in _read_from_socket raise TimeoutError("Timeout reading from socket") redis.exceptions.TimeoutError: Timeout reading from socket
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: This fix should not be used if the application relies on the original timeout behavior.\n\n

Why This Fix Works in Production

  • Trigger: >> import redis
  • Mechanism: The retry_on_timeout parameter is not propagated to the ConnectionPool during Redis client initialization
  • Why the fix works: Fixes the issue of timeout retrying not working during Redis Pipeline execution by using `retry_on_error` instead of `retry_on_timeout` inside `_disconnect_raise_reset`. (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.10.10 in real deployments (not just unit tests).
  • The retry_on_timeout parameter is not propagated to the ConnectionPool during Redis client initialization
  • Surfaces as: >> import redis

Proof / Evidence

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

Discussion

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

“I note that this bug also affects instances of PubSub”
@mburcher · 2023-08-02 · source

Failure Signature (Search String)

  • >> import redis

Error Message

Stack trace
error.txt
Error Message ------------- >> import redis >> redis_cli = redis.Redis(socket_timeout=10, retry_on_timeout=True) >> pubsub = redis_cli.pubsub() >> pubsub.subscribe("channel") >> for item in pubsub.listen(): ... print(item["type"]) ... subscribe Traceback (most recent call last): File "/venv_test/lib/python3.7/site-packages/redis/connection.py", line 210, in _read_from_socket data = self._sock.recv(socket_read_size) socket.timeout: timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/venv_test/lib/python3.7/site-packages/redis/client.py", line 1664, in listen response = self.handle_message(self.parse_response(block=True)) File "/venv_test/lib/python3.7/site-packages/redis/client.py", line 1542, in parse_response response = self._execute(conn, try_read) File "/venv_test/lib/python3.7/site-packages/redis/client.py", line 1520, in _execute lambda error: self._disconnect_raise_connect(conn, error), File "/venv_test/lib/python3.7/site-packages/redis/retry.py", line 49, in call_with_retry fail(error) File "/venv_test/lib/python3.7/site-packages/redis/client.py", line 1520, in <lambda> lambda error: self._disconnect_raise_connect(conn, error), File "/venv_test/lib/python3.7/site-packages/redis/client.py", line 1507, in _disconnect_raise_connect raise error Fil ... (truncated) ...

Minimal Reproduction

repro.py
>> import redis >> redis_cli = redis.Redis(socket_timeout=10, retry_on_timeout=True) >> pubsub = redis_cli.pubsub() >> pubsub.subscribe("channel") >> for item in pubsub.listen(): ... print(item["type"]) ... subscribe Traceback (most recent call last): File "/venv_test/lib/python3.7/site-packages/redis/connection.py", line 210, in _read_from_socket data = self._sock.recv(socket_read_size) socket.timeout: timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/venv_test/lib/python3.7/site-packages/redis/client.py", line 1664, in listen response = self.handle_message(self.parse_response(block=True)) File "/venv_test/lib/python3.7/site-packages/redis/client.py", line 1542, in parse_response response = self._execute(conn, try_read) File "/venv_test/lib/python3.7/site-packages/redis/client.py", line 1520, in _execute lambda error: self._disconnect_raise_connect(conn, error), File "/venv_test/lib/python3.7/site-packages/redis/retry.py", line 49, in call_with_retry fail(error) File "/venv_test/lib/python3.7/site-packages/redis/client.py", line 1520, in <lambda> lambda error: self._disconnect_raise_connect(conn, error), File "/venv_test/lib/python3.7/site-packages/redis/client.py", line 1507, in _disconnect_raise_connect raise error File "/venv_test/lib/python3.7/site-packages/redis/retry.py", line 46, in call_with_retry return do() File "/venv_test/lib/python3.7/site-packages/redis/client.py", line 1519, in <lambda> lambda: command(*args, **kwargs), File "/venv_test/lib/python3.7/site-packages/redis/client.py", line 1540, in try_read return conn.read_response(disconnect_on_error=False) File "/venv_test/lib/python3.7/site-packages/redis/connection.py", line 874, in read_response response = self._parser.read_response(disable_decoding=disable_decoding) File "/venv_test/lib/python3.7/site-packages/redis/connection.py", line 347, in read_response result = self._read_response(disable_decoding=disable_decoding) File "/venv_test/lib/python3.7/site-packages/redis/connection.py", line 357, in _read_response raw = self._buffer.readline() File "/venv_test/lib/python3.7/site-packages/redis/connection.py", line 260, in readline self._read_from_socket() File "/venv_test/lib/python3.7/site-packages/redis/connection.py", line 223, in _read_from_socket raise TimeoutError("Timeout reading from socket") redis.exceptions.TimeoutError: Timeout reading from socket

Environment

  • Python: 3.10.10

What Broke

Timeouts occur during pipeline execution, leading to unhandled TimeoutError exceptions.

Why It Broke

The retry_on_timeout parameter is not propagated to the ConnectionPool during Redis client initialization

Fix Options (Details)

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

pip install redis==7.1.0

When NOT to use: This fix should not be used if the application relies on the original timeout behavior.

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/2812

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

  • This fix should not be used if the application relies on the original timeout behavior.

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 TLS smoke test that performs a real handshake in CI (include CA bundle validation and hostname checks).
  • Alert on handshake failures by error string and endpoint to catch cert/CA changes 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.