-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 #2153
Comments
Ping @stephsamson |
The same warning I got while doing:
Python 3.9 and Ubuntu 18.04 |
Relates to: python-poetry#2153 When running `poetry update`, during the download phase when `PYTHONWARNINGS="default"` environment variable is set, multiple different sessions trigger resource warnings. This fixes one of them that occurs during the download phase of the package update. ``` /Users/username/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/executor.py:594: ResourceWarning: unclosed <ssl.SSLSocket fd=5, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('REDACTED', 59025), raddr=('140.108.3.33', 80)> ``` This line references: ``` 593 │ try: 594 │ archive = self._download_archive(operation, link) 595 │ except BaseException: 596 │ cache_directory = self._chef.get_cache_directory_for_link(link) ``` The issue is being caused because the session is being left open when the class is later cleaned up. By adding a destructor method, we can close the session if it exists, preventing this error.
Relates to: python-poetry#2153 When running `poetry update`, during the download phase when `PYTHONWARNINGS="default"` environment variable is set, multiple different sessions trigger resource warnings. This fixes one of them that occurs during the download phase of the package update. ``` /Users/username/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/executor.py:594: ResourceWarning: unclosed <ssl.SSLSocket fd=5, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('REDACTED', 59025), raddr=('140.108.3.33', 80)> ``` This line references: ``` 593 │ try: 594 │ archive = self._download_archive(operation, link) 595 │ except BaseException: 596 │ cache_directory = self._chef.get_cache_directory_for_link(link) ``` The issue is being caused because the session is being left open when the class is later cleaned up. By adding a destructor method, we can close the session if it exists, preventing this error.
Relates to: python-poetry#2153 When running `poetry update`, during the download phase when `PYTHONWARNINGS="default"` environment variable is set, multiple different sessions trigger resource warnings. This fixes one of them that occurs during the download phase of the package update. ``` /Users/username/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/executor.py:594: ResourceWarning: unclosed <ssl.SSLSocket fd=5, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('REDACTED', 59025), raddr=('140.108.3.33', 80)> ``` This line references: ``` 593 │ try: 594 │ archive = self._download_archive(operation, link) 595 │ except BaseException: 596 │ cache_directory = self._chef.get_cache_directory_for_link(link) ``` The issue is being caused because the session is being left open when the class is later cleaned up. By adding a destructor method, we can close the session if it exists, preventing this error.
PR submitted. If this is bugging you the patch locally is pretty simple also. ~8 or so lines. The root of the issue is that a session with keep alive behavior is used but the session is not being explicitly closed at the time the class gets cleaned up by the garbage collector after it's done being used. |
Perfect, thank you.
I will apply and test it locally in the evening.
…On Fri, 15 Oct 2021, 13:11 Kevin Kirsche ***@***.***> wrote:
PR submitted. If this is bugging you the patch locally is pretty simple
also. ~8 or so lines.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2153 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABCH53ZFTPDHDWMYHUYZPPLUHAD55ANCNFSM4LD4DOFQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
The fix works for me with Poetry (version 1.2.0a2) and Python 3.10 |
Relates to: python-poetry#2153 When running `poetry update`, during the download phase when `PYTHONWARNINGS="default"` environment variable is set, multiple different sessions trigger resource warnings. This fixes one of them that occurs during the download phase of the package update. ``` /Users/username/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/executor.py:594: ResourceWarning: unclosed <ssl.SSLSocket fd=5, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('REDACTED', 59025), raddr=('140.108.3.33', 80)> ``` This line references: ``` 593 │ try: 594 │ archive = self._download_archive(operation, link) 595 │ except BaseException: 596 │ cache_directory = self._chef.get_cache_directory_for_link(link) ``` The issue is being caused because the session is being left open when the class is later cleaned up. By adding a destructor method, we can close the session if it exists, preventing this error.
Relates to: #2153 When running `poetry update`, during the download phase when `PYTHONWARNINGS="default"` environment variable is set, multiple different sessions trigger resource warnings. This fixes one of them that occurs during the download phase of the package update. ``` /Users/username/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/executor.py:594: ResourceWarning: unclosed <ssl.SSLSocket fd=5, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('REDACTED', 59025), raddr=('140.108.3.33', 80)> ``` This line references: ``` 593 │ try: 594 │ archive = self._download_archive(operation, link) 595 │ except BaseException: 596 │ cache_directory = self._chef.get_cache_directory_for_link(link) ``` The issue is being caused because the session is being left open when the class is later cleaned up. By adding a destructor method, we can close the session if it exists, preventing this error.
Relates to: python-poetry#2153 When running `poetry update`, during the download phase when `PYTHONWARNINGS="default"` environment variable is set, multiple different sessions trigger resource warnings. This fixes one of them that occurs during the download phase of the package update. ``` /Users/username/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/executor.py:594: ResourceWarning: unclosed <ssl.SSLSocket fd=5, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('REDACTED', 59025), raddr=('140.108.3.33', 80)> ``` This line references: ``` 593 │ try: 594 │ archive = self._download_archive(operation, link) 595 │ except BaseException: 596 │ cache_directory = self._chef.get_cache_directory_for_link(link) ``` The issue is being caused because the session is being left open when the class is later cleaned up. By adding a destructor method, we can close the session if it exists, preventing this error.
Relates to: python-poetry#2153 When running `poetry update`, during the download phase when `PYTHONWARNINGS="default"` environment variable is set, multiple different sessions trigger resource warnings. This fixes one of them that occurs during the download phase of the package update. ``` /Users/username/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/installation/executor.py:594: ResourceWarning: unclosed <ssl.SSLSocket fd=5, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('REDACTED', 59025), raddr=('140.108.3.33', 80)> ``` This line references: ``` 593 │ try: 594 │ archive = self._download_archive(operation, link) 595 │ except BaseException: 596 │ cache_directory = self._chef.get_cache_directory_for_link(link) ``` The issue is being caused because the session is being left open when the class is later cleaned up. By adding a destructor method, we can close the session if it exists, preventing this error.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Issue
If i run python with warnings enabled (set the env var
PYTHONWARNINGS="default"
), and try to dopoetry update
or any remote connection related operation i get the following message:Poetry version 1.0.5
Python 3.8.2 x64
Windows 10
Update: added the fuller message with the location of the warning in code:
C:\Users\<username>\.poetry\lib\poetry\console\application.py:54:
The text was updated successfully, but these errors were encountered: