Skip to content

Fix resource warnings: unclosed sockets / SSL sockets / a PEM file#290

Open
kurtmckee wants to merge 1 commit intovalkey-io:mainfrom
kurtmckee:fix-resource-warnings
Open

Fix resource warnings: unclosed sockets / SSL sockets / a PEM file#290
kurtmckee wants to merge 1 commit intovalkey-io:mainfrom
kurtmckee:fix-resource-warnings

Conversation

@kurtmckee
Copy link
Copy Markdown
Contributor

@kurtmckee kurtmckee commented Mar 25, 2026

Description of change

This fixes a number of resource warnings reported by pytest.

One exists in the test suite itself -- an unclosed PEM file -- but the rest are unclosed sockets and SSL sockets that are problems in the package itself.

The warnings shown below are representative:

ResourceWarning: unclosed <ssl.SSLSocket ...>
ResourceWarning: unclosed <socket.socket ...>
ResourceWarning: unclosed file <_io.BufferedReader name='dockers/stunnel/keys/server-cert.pem'>

Note

This PR DOES NOT resolve all of the warnings that are thrown in the test suite!

There is a lot of work to do on the test suite's warnings, but this is an initial salvo that resolves the warnings that are displayed when running make tests locally.

Pull Request check-list

  • Do tests and lints pass with this change?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?

This fixes a number of resource warnings reported by pytest.

One exists in the test suite itself -- an unclosed PEM file --
but the rest are unclosed sockets and SSL sockets.

The warnings shown below are representative:

```
ResourceWarning: unclosed <ssl.SSLSocket ...>
ResourceWarning: unclosed <socket.socket ...>
ResourceWarning: unclosed file <_io.BufferedReader name='dockers/stunnel/keys/server-cert.pem'>
```

Signed-off-by: Kurt McKee <[email protected]>
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 1, 2026

Codecov Report

❌ Patch coverage is 0% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.37%. Comparing base (5c9a506) to head (9da735c).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
valkey/connection.py 0.00% 17 Missing ⚠️
tests/test_ssl.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #290      +/-   ##
==========================================
- Coverage   76.41%   76.37%   -0.04%     
==========================================
  Files         129      129              
  Lines       34065    34076      +11     
==========================================
- Hits        26031    26027       -4     
- Misses       8034     8049      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kurtmckee
Copy link
Copy Markdown
Contributor Author

The patch coverage warning occurs because the test suite doesn't test with the [ocsp] extra included, so the code changed here is never run by the test suite...yet. As noted in out-of-band communication, follow-up work is needed to make CI run the OCSP tests that will exercise these code paths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants