ParallelSSH / parallel-ssh

Asynchronous parallel SSH client library.
https://parallel-ssh.org
GNU Lesser General Public License v2.1
1.21k stars 149 forks source link

Cleanup socket on connection error/timeout #346

Open kurt-cb opened 2 years ago

kurt-cb commented 2 years ago

When constructing a connection to a server, and the server is not responsive, the socket is not closed in a timely fashion and can cause a secondary exception when cleaning up in the exception handler due to the resource leak. This is

ConnectionError: ("Error connecting to host '%s:%s' - %s - retry %s/%s", 'kg-meter2', 22, 'timed out', 3, 3) E
E During handling of the above exception, another exception occurred: E
E Traceback (most recent call last): E File "/home/kgodwin/.local/lib/python3.8/site-packages/_pytest/unraisableexception.py", line 43, in _hook E self.unraisable = unraisable E ResourceWarning: unclosed <socket object, fd=23, family=2, type=1, proto=0>