Skip to content

Commit 6e551e0

Browse files
committed
Improve subprocess loop
1 parent c858546 commit 6e551e0

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

src/python/knnPerfTest.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -388,14 +388,13 @@ def run_knn_benchmark(checkout, values, log_path):
388388
re_summary = re.compile(r"^SUMMARY: (.*?)$", re.MULTILINE)
389389
summary = None
390390
hit_exception = False
391-
lines = ""
392-
while True:
391+
while job.poll() is None:
393392
line = job.stdout.readline()
394-
if line == "":
395-
break
396-
lines += line
393+
if not line:
394+
continue
397395
if NOISY:
398396
sys.stdout.write(line)
397+
sys.stdout.flush()
399398
m = re_summary.match(line)
400399
if m is not None:
401400
summary = m.group(1)
@@ -420,11 +419,11 @@ def run_knn_benchmark(checkout, values, log_path):
420419

421420
if hit_exception:
422421
raise RuntimeError("unhandled java exception while running")
423-
if summary is None:
424-
raise RuntimeError("could not find summary line in output! " + lines)
425422
job.wait()
426423
if job.returncode != 0:
427424
raise RuntimeError(f"command failed with exit {job.returncode}")
425+
if summary is None:
426+
raise RuntimeError("could not find summary line in output! ")
428427
all_results.append((summary, args))
429428
if DO_PROFILING:
430429
benchUtil.profilerOutput(constants.JAVA_EXE, jfr_output, benchUtil.checkoutToPath(checkout), 30, (1,))

0 commit comments

Comments
 (0)