Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: clean up HTTP session and pool during tear down phase #1007

Merged
merged 2 commits into from
Apr 6, 2022

Conversation

lidizheng
Copy link
Contributor

@lidizheng lidizheng commented Apr 5, 2022

With help from @parthea , we are able to pin point the "creator" of the SSLSocket causing grpc/grpc#29227.

This PR cleans the HTTP resources in the __del__ methods.

Fixes: grpc/grpc#29227
Fixes: googleapis/python-secret-manager#271

@lidizheng lidizheng changed the title Clean up HTTP session and pool during tear down phase fix: clean up HTTP session and pool during tear down phase Apr 5, 2022
@lidizheng lidizheng force-pushed the clean-up branch 2 times, most recently from 9bb80e6 to 12ad314 Compare April 5, 2022 20:32
@arithmetic1728
Copy link
Contributor

Is it possible to add a simple test?

@lidizheng
Copy link
Contributor Author

@arithmetic1728 It might be a non-trivial task. In the original reproduction, we rely on the warning message printed to console to know if the socket is leaked. If there isn't a memory-leak-detection job, it would be tricky to create an ad-hoc one.

Alternatively... we can add a test to explicitly invoke Request.__del__ to see if session is closed. Do you think this will be useful?

@arithmetic1728
Copy link
Contributor

@lidizheng yes that works. We just need some simple mock tests to cover the newly added lines.

@parthea parthea added the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 5, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 5, 2022
@arithmetic1728
Copy link
Contributor

tests/transport/test_urllib3.py::TestRequestResponse::test_clear_pool_on_def failed.

I will fix the lint, and system test issue in a separate PR, they are not related to your change.

* Add unit tests for the change
* Fix the unittest to test on the correct class
* Make linter happy
@arithmetic1728 arithmetic1728 added the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 6, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 6, 2022
@arithmetic1728 arithmetic1728 merged commit d057376 into googleapis:main Apr 6, 2022
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.

ResourceWarning: unclosed SSLSocket ResourceWarning: unclosed SSLSocket
3 participants