I got the following ssh command,
try:
print 'trying to restart'
self.ssh.exec_command(RR_CMD % (self.path_ext, self.rport), timeout=1)
print 'restarted'
except:
self.ssh.close()
self.ssh = ssh.create_ssh_client(self.ip, self.port, self. username, self.password)
self.restart()
Basically I'm trying to restart a remote perl script. But sometimes, like let's say 1 out of 2000 - my python program is freezing over the exec_command line for sometimes up to a few minutes!
I would like to use the timeout function, which I set to 1 second, but it doesn't work for some reason.