Skip to content

Commit

Permalink
make sure that *all* stdout/stderr output is read when streaming outp…
Browse files Browse the repository at this point in the history
…ut or running interactive commands
  • Loading branch information
boegel committed Feb 21, 2024
1 parent bd217f8 commit 8d4e59e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions easybuild/tools/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,6 @@ def to_cmd_str(cmd):
# -1 means reading until EOF
read_size = 128 if exit_code is None else -1

exit_code = proc.poll()

more_stdout = proc.stdout.read1(read_size) or b''
stdout += more_stdout

Expand All @@ -380,6 +378,12 @@ def to_cmd_str(cmd):
raise EasyBuildError(error_msg)

time.sleep(check_interval_secs)

exit_code = proc.poll()

stdout += proc.stdout.read()
if split_stderr:
stderr += proc.stderr.read()
else:
(stdout, stderr) = proc.communicate(input=stdin)

Expand Down

0 comments on commit 8d4e59e

Please sign in to comment.