Skip to content

Commit

Permalink
Change with ... Popen() to run() instead.
Browse files Browse the repository at this point in the history
This will be more compatible with the changes, and keep the return type
the same as `run_subprocess()`

- universal_newline was changed to text in recent versions of the
  library
  • Loading branch information
favilo committed Feb 2, 2024
1 parent a2ee76e commit cbe0e4c
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions esrally/utils/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit cbe0e4c

Please sign in to comment.