Skip to content
10 changes: 7 additions & 3 deletions easybuild/tools/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,6 @@ def to_cmd_str(cmd):
if not hidden:
_cmd_trace_msg(cmd_str, start_time, work_dir, stdin, tmpdir, thread_id, interactive=interactive)

if stream_output:
print_msg(f"(streaming) output for command '{cmd_str}':")

# use bash as shell instead of the default /bin/sh used by subprocess.run
# (which could be dash instead of bash, like on Ubuntu, see https://wiki.ubuntu.com/DashAsBinSh)
# stick to None (default value) when not running command via a shell
Expand Down Expand Up @@ -512,6 +509,13 @@ def to_cmd_str(cmd):

if stream_output or qa_patterns:

if stream_output:
# enable non-blocking reading of output
print_msg(f"(streaming) output for command '{cmd_str}':")
os.set_blocking(proc.stdout.fileno(), False)
if split_stderr:
os.set_blocking(proc.stderr.fileno(), False)

if qa_patterns:
# make stdout, stderr, stdin non-blocking files
channels = [proc.stdout, proc.stdin]
Expand Down