Here is a snippet of python code that uses paramiko:
import paramiko sshClient = paramiko.SSHClient() sshClient.set_missing_host_key_policy(paramiko.AutoAddPolicy) sshClient.connect(_peerIp, username=_username, password=_password, timeout=3.0)
As soon as I ran the script, I also unplugged the _peerIp network cable. And the connect () method freezes. Although the timeout is 3.0, it lasts 10 minutes and it still hangs.
(I think the TCP connection was established per second and I disconnected the cable during the ssh installation)
So, do you know about this in a workaround? My script will work in the manufacture of the factory, and it should not hang in such a script and handle it properly.
EDIT:
He just gave an exception:
No handlers could be found for logger "paramiko.transport" Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/pymodules/python2.6/paramiko/client.py", line 327, in connect self._auth(username, password, pkey, key_filenames, allow_agent, look_for_keys) File "/usr/lib/pymodules/python2.6/paramiko/client.py", line 438, in _auth self._transport.auth_publickey(username, key) File "/usr/lib/pymodules/python2.6/paramiko/transport.py", line 1234, in auth_publickey return self.auth_handler.wait_for_response(my_event) File "/usr/lib/pymodules/python2.6/paramiko/auth_handler.py", line 163, in wait_for_response raise e socket.error: [Errno 113] No route to host
Well, at least in the end it threw an exception, but I think this is not the expected behavior. If the timeout is 3.0, the connect () method should return something after the timeout expires.