Fix slow ssh

We break the read while loop after waiting "the end of the process" and
the pipes are empty, otherwise we do another select that waits all the
timeout.
This commit is contained in:
Luca Berruti 2014-02-05 09:45:03 +01:00
parent a0f91f2aaa
commit 75b7a1d9c7
2 changed files with 6 additions and 0 deletions

View file

@ -303,6 +303,9 @@ class Connection(object):
# Calling wait while there are still pipes to read can cause a lock # Calling wait while there are still pipes to read can cause a lock
elif not rpipes and p.poll() == None: elif not rpipes and p.poll() == None:
p.wait() p.wait()
# the process has finished and the pipes are empty,
# if we loop and do the select it waits all the timeout
break
stdin.close() # close stdin after we read from stdout (see also issue #848) stdin.close() # close stdin after we read from stdout (see also issue #848)
if C.HOST_KEY_CHECKING and not_in_host_file: if C.HOST_KEY_CHECKING and not_in_host_file:

View file

@ -261,6 +261,9 @@ class Connection(object):
# Calling wait while there are still pipes to read can cause a lock # Calling wait while there are still pipes to read can cause a lock
elif not rpipes and p.poll() == None: elif not rpipes and p.poll() == None:
p.wait() p.wait()
# the process has finished and the pipes are empty,
# if we loop and do the select it waits all the timeout
break
stdin.close() # close stdin after we read from stdout (see also issue #848) stdin.close() # close stdin after we read from stdout (see also issue #848)
if C.HOST_KEY_CHECKING and not_in_host_file: if C.HOST_KEY_CHECKING and not_in_host_file: