Jump to solution
Details

The Fix

pip install redis==7.1.0

Based on closed redis/redis-py issue #2138 · 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%.

Open PR/Commit
@@ -911,7 +911,13 @@ async def can_read(self, timeout: float = 0): if not self.is_connected: await self.connect() - return await self._parser.can_read(timeout) + try: + return await self._parser.can_read(timeout)
fix.md
Option A — Upgrade to fixed release\npip install redis==7.1.0\nWhen NOT to use: Do not use this fix if you require original OSError behavior for debugging.\n\n

Why This Fix Works in Production

  • Trigger: `connection.can_read()` raises OSError when connection is broken
  • Mechanism: The can_read method does not handle OSError exceptions, causing them to bubble up
  • Why the fix works: Replaces OSError exceptions from the `can_read` method with `redis.ConnectionError`, improving error handling during connection issues. (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

  • The can_read method does not handle OSError exceptions, causing them to bubble up
  • Surfaces as: `connection.can_read()` raises OSError when connection is broken

Proof / Evidence

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

Discussion

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

“**Version**: 4.2.2 **Platform**: Windows 11 **Description**: redis.asyncio.connection.Connection(), the class provides a can_read method, which is used, for example, in Client.parse_response. However, unlike Connection.read_response() there”
Issue thread · issue description · source

Failure Signature (Search String)

  • `connection.can_read()` raises OSError when connection is broken

Error Message

Stack trace
error.txt
Error Message ------------- `connection.can_read()` raises OSError when connection is broken

What Broke

Connection interruptions during blocking calls lead to unhandled OSErrors.

Why It Broke

The can_read method does not handle OSError exceptions, causing them to bubble up

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 you require original OSError behavior for debugging.

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

First fixed release: 7.1.0

Last verified: 2026-02-07. 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 you require original OSError behavior for debugging.

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.
  • Make timeouts explicit and test them (unit + integration) to avoid silent behavior changes.
  • Instrument retries (attempt count + reason) and alert on spikes to catch dependency slowdowns.

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.