mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-07-29 11:55:04 +00:00
Avoid losing data from events if multiple arrive at the same time. (#1158)
This commit is contained in:
@@ -177,21 +177,24 @@ class Connection(ConnectionBase):
|
||||
+ to_native(become_output)
|
||||
)
|
||||
|
||||
chunk = None
|
||||
chunks = b""
|
||||
for key, event in events:
|
||||
if key.fileobj == p.stdout:
|
||||
chunk = p.stdout.read()
|
||||
if chunk:
|
||||
chunks += chunk
|
||||
elif key.fileobj == p.stderr:
|
||||
chunk = p.stderr.read()
|
||||
# TODO: avoid chunk being set multiple times!
|
||||
if chunk:
|
||||
chunks += chunk
|
||||
|
||||
if not chunk:
|
||||
if not chunks:
|
||||
stdout, stderr = p.communicate()
|
||||
raise AnsibleError(
|
||||
"privilege output closed while waiting for password prompt:\n"
|
||||
+ to_native(become_output)
|
||||
)
|
||||
become_output += chunk
|
||||
become_output += chunks
|
||||
finally:
|
||||
selector.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user