Skip to content

Commit 0825d42

Browse files
committed
don't read any output in check_async_cmd if output_read_size is set to 0
1 parent e47fead commit 0825d42

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

easybuild/tools/run.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,10 @@ def check_async_cmd(proc, cmd, owd, start_time, cmd_log, output_read_size=1024,
263263
:result: dict value with result of the check (boolean 'done', 'exit_code', 'output')
264264
"""
265265
# use small read size, to avoid waiting for a long time until sufficient output is produced
266-
add_out = get_output_from_process(proc, read_size=output_read_size)
267-
_log.debug("Additional output from asynchronous command '%s': %s" % (cmd, add_out))
268-
output += add_out
266+
if output_read_size:
267+
add_out = get_output_from_process(proc, read_size=output_read_size)
268+
_log.debug("Additional output from asynchronous command '%s': %s" % (cmd, add_out))
269+
output += add_out
269270

270271
exit_code = proc.poll()
271272
if exit_code is None:

test/framework/run.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,13 @@ def test_run_cmd_async(self):
639639

640640
# also test use of check_async_cmd on verbose test command
641641
cmd_info = run_cmd(verbose_test_cmd, asynchronous=True)
642+
643+
# with output_read_size set to 0, no output is read yet, only status of command is checked
644+
res = check_async_cmd(*cmd_info, output_read_size=0)
645+
self.assertEqual(res['done'], False)
646+
self.assertEqual(res['exit_code'], None)
647+
self.assertEqual(res['output'], '')
648+
642649
res = check_async_cmd(*cmd_info)
643650
self.assertEqual(res['done'], False)
644651
self.assertEqual(res['exit_code'], None)

0 commit comments

Comments
 (0)