Python parallel-ssh run_command does not timeout when using pssh.clients

1.1k views Asked by At

I have the following code:

from pssh.clients import ParallelSSHClient
#-------------------------------------------------

hosts = [ IP1, IP2, ... IPn]
host_config = { dict containing userid & passwd for each host }

clients = ParallelSSHClient(hosts, host_config=host_config,
                           num_retries=1, timeout=3)

output = clients.run_command("ls", stop_on_errors=False, timeout=3)
print output

If my hosts have all valid IPs, then I get "output". However, if even one of the IPs is invalid (non-existing host), then the run_command hangs forever. Even tried using "use_pty=True" argument to run_command.

Strange thing is that if I use the deprecated method pssh_client instead of clients like follows:

from pssh.pssh_client import ParallelSSHClient

it times-out as expected. Either there is a bug introduced with the new way of importing or there is some new way to specify timeout properly. I would prefer to use the recommended way instead of the deprecated way. But recommended way is not working for me. Anyone know if I am doing something wrong here ?

1

There are 1 answers

0
Gopal On

This has been confirmed as a bug on the ParallelSSH's github site. Hence, this issue is closed. Issue was listed at:

https://github.com/ParallelSSH/parallel-ssh/issues/133