From 61d99ccbe8af71de057405fe38627b2c20006044 Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Fri, 27 Jun 2025 18:57:06 +0100 Subject: [PATCH 1/4] Read from channels until they are closed Instead of stopping when the process terminate, continue reading until all channels are closed. Signed-off-by: Stefan Marr --- rebench/subprocess_with_timeout.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/rebench/subprocess_with_timeout.py b/rebench/subprocess_with_timeout.py index 804c88a1..54378595 100644 --- a/rebench/subprocess_with_timeout.py +++ b/rebench/subprocess_with_timeout.py @@ -92,11 +92,17 @@ def process_output(self, proc): self.stderr_result = "" while True: - reads = [proc.stdout.fileno()] - if self._stderr == PIPE: + reads = [] + + if proc.stdout and not proc.stdout.closed: + reads.append(proc.stdout.fileno()) + if self._stderr == PIPE and proc.stderr and not proc.stderr.closed: reads.append(proc.stderr.fileno()) - ret = select(reads, [], []) + if not reads: + break + + ret = select(reads, [], []) for file_no in ret[0]: if file_no == proc.stdout.fileno(): read = output_as_str(proc.stdout.readline()) @@ -106,9 +112,6 @@ def process_output(self, proc): read = output_as_str(proc.stderr.readline()) sys.stderr.write(read) self.stderr_result += read - - if proc.poll() is not None: - break else: stdout_r, stderr_r = proc.communicate() self.stdout_result = output_as_str(stdout_r) From 96d516bc81e47f42e950cd6895a3ac53c05608bc Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Fri, 27 Jun 2025 20:10:36 +0100 Subject: [PATCH 2/4] Detect End Of File on stdout and stderr while reading The previous code lifelocked on the EOF markers, i.e., empty strings. Signed-off-by: Stefan Marr --- rebench/subprocess_with_timeout.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/rebench/subprocess_with_timeout.py b/rebench/subprocess_with_timeout.py index 54378595..4ff103b6 100644 --- a/rebench/subprocess_with_timeout.py +++ b/rebench/subprocess_with_timeout.py @@ -91,27 +91,39 @@ def process_output(self, proc): self.stdout_result = "" self.stderr_result = "" + stdout_eof = False + stderr_eof = False + while True: reads = [] - if proc.stdout and not proc.stdout.closed: + if proc.stdout and not proc.stdout.closed and not stdout_eof: reads.append(proc.stdout.fileno()) - if self._stderr == PIPE and proc.stderr and not proc.stderr.closed: + if (self._stderr == PIPE and + proc.stderr and + not proc.stderr.closed and + not stderr_eof): reads.append(proc.stderr.fileno()) if not reads: break - ret = select(reads, [], []) + ret = select(reads, [], [], 0.1) for file_no in ret[0]: if file_no == proc.stdout.fileno(): read = output_as_str(proc.stdout.readline()) - sys.stdout.write(read) - self.stdout_result += read + if read == "": + stdout_eof = True + else: + sys.stdout.write(read) + self.stdout_result += read if self._stderr == PIPE and file_no == proc.stderr.fileno(): read = output_as_str(proc.stderr.readline()) - sys.stderr.write(read) - self.stderr_result += read + if read == "": + stderr_eof = True + else: + sys.stderr.write(read) + self.stderr_result += read else: stdout_r, stderr_r = proc.communicate() self.stdout_result = output_as_str(stdout_r) From 213e33dfcf35b381b36c798ee4d0ba6a6e812562 Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Fri, 27 Jun 2025 20:56:21 +0100 Subject: [PATCH 3/4] Need to call wait() to make sure we get the return code Signed-off-by: Stefan Marr --- rebench/subprocess_with_timeout.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rebench/subprocess_with_timeout.py b/rebench/subprocess_with_timeout.py index 4ff103b6..98cc0ca7 100644 --- a/rebench/subprocess_with_timeout.py +++ b/rebench/subprocess_with_timeout.py @@ -106,6 +106,7 @@ def process_output(self, proc): reads.append(proc.stderr.fileno()) if not reads: + proc.wait() break ret = select(reads, [], [], 0.1) From 0951a2e30edce6f3346ff535b1623327252c10bc Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Sat, 28 Jun 2025 14:55:49 +0100 Subject: [PATCH 4/4] Use empty string to display a missing unit Signed-off-by: Stefan Marr --- rebench/executor.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rebench/executor.py b/rebench/executor.py index bb7cc29d..87abb7ea 100644 --- a/rebench/executor.py +++ b/rebench/executor.py @@ -108,6 +108,8 @@ def _indicate_progress(self, completed_task, run): art_mean = run.get_mean_of_totals() art_unit = run.total_unit + if art_unit is None: + art_unit = "" hour, minute, sec = self._estimate_time_left()