diff --git a/esrally/utils/process.py b/esrally/utils/process.py index d46de65b6..8dc2553c9 100644 --- a/esrally/utils/process.py +++ b/esrally/utils/process.py @@ -99,21 +99,22 @@ def run_subprocess_with_logging( logger.info(header) # pylint: disable=subprocess-popen-preexec-fn - with subprocess.Popen( + completed = subprocess.run( command_line_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, - universal_newlines=True, + text=True, env=env, stdin=stdin if stdin else None, + check=False, preexec_fn=pre_exec, - ) as command_line_process: - stdout, _ = command_line_process.communicate() - if stdout: - logger.log(level=level, msg=stdout) + ) + + for line in completed.stdout.splitlines(): + logger.log(level=level, msg=line) - logger.debug("Subprocess [%s] finished with return code [%s].", command_line, str(command_line_process.returncode)) - return command_line_process + logger.debug("Subprocess [%s] finished with return code [%s].", command_line, str(completed.returncode)) + return completed def is_rally_process(p: psutil.Process) -> bool: