-
Notifications
You must be signed in to change notification settings - Fork 146
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
ResourceWarning: unclosed socket #1812
Comments
Thanks for the issue, but I don't think this is something we'd bother fixing. |
I have come across essentially the same issue. In my eyes, despite the length of the example code above, the problem lies more or less in
That it's a very old issue rooted deep in the Python code. However, if the very useful discussion in https://emptysqua.re/blog/against-resourcewarnings-in-python-3/#comment-514722438 is still current, that warning is off by default, and
So modifying that warnings filter more carefully might fix the warnings output. Still, since this warning
... I wonder if debugpy could go ahead and just explicitly close their socket(s) instead of relying on the Python garbage collector to do so. Happy to help with a PR if someone can point me into the right direction (any maybe hint at why this is not an obvious one-liner, if it isn't). |
This might be where you'd start. It's the handling of shutting down when the debugger is exiting: https://vscode.dev/github/microsoft/debugpy/blob/main/src/debugpy/adapter/sessions.py#L135 |
Thanks, I think I got somewhere! Instructions: rem Install https://marketplace.visualstudio.com/items?itemName=ms-python.debugpy, v2024.14.0
cd %USERPROFILE%\.vscode\extensions\ms-python.debugpy-2024.14.0-win32-x64\bundled\libs
echo import warnings; warnings.filterwarnings("error") > bug.py
set PYDEVD_DISABLE_FILE_VALIDATION=1
python -m debugpy --listen 5000 bug.py See
Then replace Re-run
See
(nothing) Voila! I am 99% sure there is better location for the closing of the socket, but I am happy I got this prototype to begin with. |
For the record, simpler reproduction checks not requiring VS Code at all: checkout
|
Environment data
Actual behavior
getting unclosed socket warning only when running via debbuger (only extension installed is python + pylance + debugpy):
Expected behavior
should not pop
Steps to reproduce:
here is a full code repro:
output:
The text was updated successfully, but these errors were encountered: