Avoid ResourceWarning if shutdown failed for some reason#272
Merged
auvipy merged 3 commits intoLawouach:masterfrom Dec 24, 2024
Merged
Avoid ResourceWarning if shutdown failed for some reason#272auvipy merged 3 commits intoLawouach:masterfrom
auvipy merged 3 commits intoLawouach:masterfrom
Conversation
Typically it looks like this:
/home/user/.local/lib/python3.8/site-packages/ws4py/websocket.py:230: ResourceWarning: unclosed <ssl.SSLSocket fd=8, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('10.200.11.18', 40248)>
Contributor
Author
|
I've provided a test to reproduce the problem. |
auvipy
requested changes
May 21, 2023
Collaborator
auvipy
left a comment
There was a problem hiding this comment.
is it possible to add the test in the test suite?
Contributor
Author
I'm not sure. This test is "dirty", it reassigns methods in system classes, I'm not sure it's a good idea to add it to the test suite. |
Contributor
Author
Done. |
auvipy
requested changes
Dec 24, 2024
Signed-off-by: Asif Saif Uddin <auvipy@gmail.com>
auvipy
approved these changes
Dec 24, 2024
Contributor
Author
|
Thanks!! It's sad it missed the release. :( |
Collaborator
|
no worries, we can include it in next release, can you add/improve test coverage for this change? |
Contributor
Author
|
Year, next release would be great! I don't see a good way to improve test coverage in this matter, the test for this is too dirty to be run in some test set. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The following warning appears transiently from time to time while working with websockets:
Investigation shows that this warning appears if
self.sock.shutdown(socket.SHUT_RDWR)(line 225) throws exception and thusself.sock.close()(line 226) is not called and execution proceeds straight toself.sock = None(line 230), and that produces theResourceWarningmentioned above.The exception itself is hidden by
passstatement (line 228), but additional investigation showed the following example of that exception:The reliable reproduction of this situation is problematic, but I've created the following test that reproduces the problem reliably and should pass if the problem is fixed:
Here's the output: