The Fix
pip install redis==7.1.0
Based on closed redis/redis-py issue #2749 · PR/commit linked
@@ -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
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(...)
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
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…”
“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.”
“@dvora-h As you're getting a 4.5.5 ready, I wonder if some of @kristjanvalur recent contributions address this!”
“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…”
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
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 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
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
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.
When NOT to Use This Fix
- Do not apply this fix if your application relies on custom cleanup logic in __del__.
Verify Fix
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
| Version | Status |
|---|---|
| 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.