mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 11:51:26 -07:00
Merge pull request #4920 from iffy/ansible
Collect all stdout over ssh transport before returning data
This commit is contained in:
parent
441cd1c5b9
commit
389602b8dd
1 changed files with 7 additions and 7 deletions
|
@ -216,8 +216,9 @@ class Connection(object):
|
||||||
# We can't use p.communicate here because the ControlMaster may have stdout open as well
|
# We can't use p.communicate here because the ControlMaster may have stdout open as well
|
||||||
stdout = ''
|
stdout = ''
|
||||||
stderr = ''
|
stderr = ''
|
||||||
|
rpipes = [p.stdout, p.stderr]
|
||||||
while True:
|
while True:
|
||||||
rfd, wfd, efd = select.select([p.stdout, p.stderr], [], [p.stdout, p.stderr], 1)
|
rfd, wfd, efd = select.select(rpipes, [], rpipes, 1)
|
||||||
|
|
||||||
# fail early if the sudo password is wrong
|
# fail early if the sudo password is wrong
|
||||||
if self.runner.sudo and sudoable and self.runner.sudo_pass:
|
if self.runner.sudo and sudoable and self.runner.sudo_pass:
|
||||||
|
@ -230,15 +231,14 @@ class Connection(object):
|
||||||
dat = os.read(p.stdout.fileno(), 9000)
|
dat = os.read(p.stdout.fileno(), 9000)
|
||||||
stdout += dat
|
stdout += dat
|
||||||
if dat == '':
|
if dat == '':
|
||||||
p.wait()
|
rpipes.remove(p.stdout)
|
||||||
break
|
if p.stderr in rfd:
|
||||||
elif p.stderr in rfd:
|
|
||||||
dat = os.read(p.stderr.fileno(), 9000)
|
dat = os.read(p.stderr.fileno(), 9000)
|
||||||
stderr += dat
|
stderr += dat
|
||||||
if dat == '':
|
if dat == '':
|
||||||
p.wait()
|
rpipes.remove(p.stderr)
|
||||||
break
|
if not rpipes or p.poll() is not None:
|
||||||
elif p.poll() is not None:
|
p.wait()
|
||||||
break
|
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)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue