mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #6788 from tyll/pull_ssh_verbose_comments
ssh connection plugin: Make comments more verbose
This commit is contained in:
commit
904f331210
1 changed files with 12 additions and 6 deletions
|
@ -151,6 +151,7 @@ class Connection(object):
|
||||||
stdin.close()
|
stdin.close()
|
||||||
except:
|
except:
|
||||||
raise errors.AnsibleError('SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh')
|
raise errors.AnsibleError('SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh')
|
||||||
|
# Read stdout/stderr from process
|
||||||
while True:
|
while True:
|
||||||
rfd, wfd, efd = select.select(rpipes, [], rpipes, 1)
|
rfd, wfd, efd = select.select(rpipes, [], rpipes, 1)
|
||||||
|
|
||||||
|
@ -177,17 +178,22 @@ class Connection(object):
|
||||||
stderr += dat
|
stderr += dat
|
||||||
if dat == '':
|
if dat == '':
|
||||||
rpipes.remove(p.stderr)
|
rpipes.remove(p.stderr)
|
||||||
# only break out if we've emptied the pipes, or there is nothing to
|
# only break out if no pipes are left to read or
|
||||||
# read from and the process has finished.
|
# the pipes are completely read and
|
||||||
|
# the process is terminated
|
||||||
if (not rpipes or not rfd) and p.poll() is not None:
|
if (not rpipes or not rfd) and p.poll() is not None:
|
||||||
break
|
break
|
||||||
# Calling wait while there are still pipes to read can cause a lock
|
# No pipes are left to read but process is not yet terminated
|
||||||
|
# Only then it is safe to wait for the process to be finished
|
||||||
|
# NOTE: Actually p.poll() is always None here if rpipes is empty
|
||||||
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,
|
# The process is terminated. Since no pipes to read from are
|
||||||
# if we loop and do the select it waits all the timeout
|
# left, there is no need to call select() again.
|
||||||
break
|
break
|
||||||
stdin.close() # close stdin after we read from stdout (see also issue #848)
|
# close stdin after process is terminated and stdout/stderr are read
|
||||||
|
# completely (see also issue #848)
|
||||||
|
stdin.close()
|
||||||
return (p.returncode, stdout, stderr)
|
return (p.returncode, stdout, stderr)
|
||||||
|
|
||||||
def not_in_host_file(self, host):
|
def not_in_host_file(self, host):
|
||||||
|
|
Loading…
Reference in a new issue