Skip to content

Commit

Permalink
ceph-volume: process: disable stdin param of run()
Browse files Browse the repository at this point in the history
we cannot use process.communicate() to feed the Popen with input,
because, upon return of process.communicate() the stdout,stderr are
closed. see https://docs.python.org/2/library/subprocess.html#subprocess.Popen.communicate .

Signed-off-by: Kefu Chai <kchai@redhat.com>
  • Loading branch information
tchaikov committed Dec 3, 2017
1 parent 46abd50 commit f62f23c
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/ceph-volume/ceph_volume/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,19 @@ def run(command, **kw):
stop_on_error = kw.pop('stop_on_error', True)
command_msg = obfuscate(command, kw.pop('obfuscate', None))
stdin = kw.pop('stdin', None)
assert 'stdin' not in kw, "'stdin' not supported by process.run()"
logger.info(command_msg)
terminal.write(command_msg)
terminal_logging = kw.pop('terminal_logging', True)

process = subprocess.Popen(
command,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=True,
**kw
)

if stdin:
process.communicate(stdin)
while True:
reads, _, _ = select(
[process.stdout.fileno(), process.stderr.fileno()],
Expand Down

0 comments on commit f62f23c

Please sign in to comment.