-
Notifications
You must be signed in to change notification settings - Fork 288
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
Avoid ResourceWarning if shutdown failed for some reason #272
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)>
I've provided a test to reproduce the problem. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to add the test in the test suite?
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you just rebase it?
Done. |
Signed-off-by: Asif Saif Uddin <[email protected]>
Thanks!! It's sad it missed the release. :( |
no worries, we can include it in next release, can you add/improve test coverage for this change? |
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. |
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 theResourceWarning
mentioned above.The exception itself is hidden by
pass
statement (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: