From 75b7a1d9c7f088a9ec5a43e618139f6276cf6a4a Mon Sep 17 00:00:00 2001 From: Luca Berruti Date: Wed, 5 Feb 2014 09:45:03 +0100 Subject: [PATCH] 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. --- lib/ansible/runner/connection_plugins/ssh.py | 3 +++ lib/ansible/runner/connection_plugins/ssh_old.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/lib/ansible/runner/connection_plugins/ssh.py b/lib/ansible/runner/connection_plugins/ssh.py index 8dd47b515a..c5fab75ce1 100644 --- a/lib/ansible/runner/connection_plugins/ssh.py +++ b/lib/ansible/runner/connection_plugins/ssh.py @@ -303,6 +303,9 @@ class Connection(object): # Calling wait while there are still pipes to read can cause a lock elif not rpipes and p.poll() == None: 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) if C.HOST_KEY_CHECKING and not_in_host_file: diff --git a/lib/ansible/runner/connection_plugins/ssh_old.py b/lib/ansible/runner/connection_plugins/ssh_old.py index db4fc24fcc..55b19a6c10 100644 --- a/lib/ansible/runner/connection_plugins/ssh_old.py +++ b/lib/ansible/runner/connection_plugins/ssh_old.py @@ -261,6 +261,9 @@ class Connection(object): # Calling wait while there are still pipes to read can cause a lock elif not rpipes and p.poll() == None: 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) if C.HOST_KEY_CHECKING and not_in_host_file: