Jump to solution
Verify

The Fix

pip install redis==7.1.0

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

Jump to Verify Open PR/Commit
@@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@ + * Fix #2749, remove unnecessary __del__ logic to close connections. * Fix #2754, adding a missing argument to SentinelManagedConnection * Fix `xadd` command to accept non-negative `maxlen` including 0
repro.py
def get_redis(read_only: bool) from redis.sentinel import Sentinel sentinel = Sentinel([(URL, PORT)]) if read_only: return sentinel.slave_for(...) return sentinel.master_for(...)
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 apply this fix if your application relies on custom cleanup logic in __del__.\n\n

Why This Fix Works in Production

  • Trigger: **Description**: Description of your issue, stack traces from errors and code that reproduces the issue
  • Mechanism: Removes unnecessary __del__ handlers that could lead to issues with pending tasks in asyncio.
  • Why the fix works: Removes unnecessary __del__ handlers that could lead to issues with pending tasks in asyncio. (first fixed release: 7.1.0).

Why This Breaks in Prod

  • Shows up under Python 3.10 in real deployments (not just unit tests).
  • Production symptom (often without a traceback): **Description**: Description of your issue, stack traces from errors and code that reproduces the issue

Proof / Evidence

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

Discussion

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

“I see. Well, quickly browsing that repo shows that it is using the regular redis.asyncio.Redis class. In which case I suspect that this problem will…”
@kristjanvalur · 2023-05-08 · confirmation · source
“It looks like this issue has been resolved, so I’ll close it for now. Feel free to reopen it if you need further assistance.”
@petyaslavova · 2025-02-04 · confirmation · source
“@dvora-h As you're getting a 4.5.5 ready, I wonder if some of @kristjanvalur recent contributions address this!”
@chayim · 2023-05-07 · source
“It looks like a task created specifically to disconnect. From what I can tell, this happens only in cluster code. Are you using a redis…”
@kristjanvalur · 2023-05-07 · source

Failure Signature (Search String)

  • **Description**: Description of your issue, stack traces from errors and code that reproduces the issue
  • We recently bumped `redis-py` to its latest version 4.5.4. After that on sentry we started to see these exceptions `Task was destroyed but it is pending!`
Copy-friendly signature
signature.txt
Failure Signature ----------------- **Description**: Description of your issue, stack traces from errors and code that reproduces the issue We recently bumped `redis-py` to its latest version 4.5.4. After that on sentry we started to see these exceptions `Task was destroyed but it is pending!`

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- **Description**: Description of your issue, stack traces from errors and code that reproduces the issue We recently bumped `redis-py` to its latest version 4.5.4. After that on sentry we started to see these exceptions `Task was destroyed but it is pending!`

Minimal Reproduction

repro.py
def get_redis(read_only: bool) from redis.sentinel import Sentinel sentinel = Sentinel([(URL, PORT)]) if read_only: return sentinel.slave_for(...) return sentinel.master_for(...)

Environment

  • Python: 3.10

What Broke

Users experienced warnings about pending tasks leading to potential resource leaks.

Fix Options (Details)

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

pip install redis==7.1.0

When NOT to use: Do not apply this fix if your application relies on custom cleanup logic in __del__.

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

First fixed release: 7.1.0

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

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • Do not apply this fix if your application relies on custom cleanup logic in __del__.

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

  • Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
  • Pin production dependencies and upgrade only with a reproducible test that hits the failing path.

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.