The Fix
pip install redis==7.1.0
Based on closed redis/redis-py issue #3317 · PR/commit linked
@@ -65,6 +65,7 @@
* Prevent async ClusterPipeline instances from becoming "false-y" in case of empty command stack (#3061)
* Close Unix sockets if the connection attempt fails. This prevents `ResourceWarning`s. (#3314)
+ * Close SSL sockets if the connection attempt fails, or if validations fail. (#3317)
* 4.1.3 (Feb 8, 2022)
Option A — Upgrade to fixed release\npip install redis==7.1.0\nWhen NOT to use: This fix should not be applied if the application relies on unclosed sockets for specific behavior.\n\n
Why This Fix Works in Production
- Trigger: Unclosed SSL sockets cause `ResourceWarning`s
- Mechanism: SSL sockets were not closed properly when a RedisError occurred during connection validations
- Why the fix works: Closes SSL sockets when connections or validations fail, addressing ResourceWarnings in the test suite. (first fixed release: 7.1.0).
Why This Breaks in Prod
- Shows up under Python 3.12 in real deployments (not just unit tests).
- SSL sockets were not closed properly when a RedisError occurred during connection validations
- Production symptom (often without a traceback): Unclosed SSL sockets cause `ResourceWarning`s
Proof / Evidence
- GitHub issue: #3317
- Fix PR: https://github.com/redis/redis-py/pull/3318
- First fixed release: 7.1.0
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.75
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.64
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“**Version**: master branch, at d1b4191f7a7918a39c1cb46e9e816389c3996233 **Platform**: Python 3.12 on Linux in CI **Description**: CI shows that the test suite opens SSL sockets but doesn't always close them, resulting in ResourceWarnings (r”
Failure Signature (Search String)
- Unclosed SSL sockets cause `ResourceWarning`s
- CI shows that the test suite opens SSL sockets but doesn't always close them, resulting in `ResourceWarning`s ([recent
Copy-friendly signature
Failure Signature
-----------------
Unclosed SSL sockets cause `ResourceWarning`s
CI shows that the test suite opens SSL sockets but doesn't always close them, resulting in `ResourceWarning`s ([recent example](https://github.com/redis/redis-py/actions/runs/9900975496/job/27352615257#step:4:301)).
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Unclosed SSL sockets cause `ResourceWarning`s
CI shows that the test suite opens SSL sockets but doesn't always close them, resulting in `ResourceWarning`s ([recent example](https://github.com/redis/redis-py/actions/runs/9900975496/job/27352615257#step:4:301)).
Environment
- Python: 3.12
What Broke
Unclosed SSL sockets lead to ResourceWarnings during test suite execution.
Why It Broke
SSL sockets were not closed properly when a RedisError occurred during connection validations
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/3318
First fixed release: 7.1.0
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be applied if the application relies on unclosed sockets for specific behavior.
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.
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.