Skip to content

Commit 79f93cc

Browse files
authored
Make sure to read all data from stdout and stderr (#290)
2 parents 33a6243 + 0951a2e commit 79f93cc

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

rebench/executor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ def _indicate_progress(self, completed_task, run):
108108

109109
art_mean = run.get_mean_of_totals()
110110
art_unit = run.total_unit
111+
if art_unit is None:
112+
art_unit = ""
111113

112114
hour, minute, sec = self._estimate_time_left()
113115

rebench/subprocess_with_timeout.py

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,24 +91,40 @@ def process_output(self, proc):
9191
self.stdout_result = ""
9292
self.stderr_result = ""
9393

94+
stdout_eof = False
95+
stderr_eof = False
96+
9497
while True:
95-
reads = [proc.stdout.fileno()]
96-
if self._stderr == PIPE:
98+
reads = []
99+
100+
if proc.stdout and not proc.stdout.closed and not stdout_eof:
101+
reads.append(proc.stdout.fileno())
102+
if (self._stderr == PIPE and
103+
proc.stderr and
104+
not proc.stderr.closed and
105+
not stderr_eof):
97106
reads.append(proc.stderr.fileno())
98-
ret = select(reads, [], [])
99107

108+
if not reads:
109+
proc.wait()
110+
break
111+
112+
ret = select(reads, [], [], 0.1)
100113
for file_no in ret[0]:
101114
if file_no == proc.stdout.fileno():
102115
read = output_as_str(proc.stdout.readline())
103-
sys.stdout.write(read)
104-
self.stdout_result += read
116+
if read == "":
117+
stdout_eof = True
118+
else:
119+
sys.stdout.write(read)
120+
self.stdout_result += read
105121
if self._stderr == PIPE and file_no == proc.stderr.fileno():
106122
read = output_as_str(proc.stderr.readline())
107-
sys.stderr.write(read)
108-
self.stderr_result += read
109-
110-
if proc.poll() is not None:
111-
break
123+
if read == "":
124+
stderr_eof = True
125+
else:
126+
sys.stderr.write(read)
127+
self.stderr_result += read
112128
else:
113129
stdout_r, stderr_r = proc.communicate()
114130
self.stdout_result = output_as_str(stdout_r)

0 commit comments

Comments
 (0)