You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With Python 3.6.3 and Paramiko 2.4.0, connecting with an invalid host or port causes a ResourceWarning (noticeable when the interpreter warnings are activated with the -Wall flag) as the underlying socket is not closed in such a case:
/home/master/.local/lib/python3.6/site-packages/paramiko/client.py:332: ResourceWarning: unclosed <socket.socket fd=4, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_STREAM, proto=0, laddr=('::', 49626, 0, 0)>
sock = socket.socket(af, socket.SOCK_STREAM)
/usr/lib/python3/dist-packages/apport/report.py:13: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import fnmatch, glob, traceback, errno, sys, atexit, locale, imp
Traceback (most recent call last):
File "", line 4, in
File "/home/master/.local/lib/python3.6/site-packages/paramiko/client.py", line 357, in connect
raise NoValidConnectionsError(errors)
paramiko.ssh_exception.NoValidConnectionsError: [Errno None] Unable to connect to port 0 on 127.0.0.1 or ::1
sys:1: ResourceWarning: unclosed <socket.socket fd=5, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('0.0.0.0', 58766)>
Activity
pkittenis commentedon Nov 30, 2017
Not just on invalid host/port, sockets are not closed in general. #1127
maludwig commentedon Dec 31, 2018
I just spent a bunch of time hunting down this error, sad that it's in Paramiko itself.
andyleejordan commentedon Oct 12, 2020
As of today, this is still the case.
Close socket on failure
bitprophet commentedon Jun 3, 2022
Rolling into #1822
Close socket on failure