From 726665e08e7f2880ad9126efea26c78adfa54b32 Mon Sep 17 00:00:00 2001 From: pllimax Date: Sat, 29 Aug 2026 01:11:02 +0800 Subject: [PATCH] [CI] Read subprocess stdout on a background thread to avoid EOF deadlock (#36673) --- python/sglang/test/ci/ci_utils.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/python/sglang/test/ci/ci_utils.py b/python/sglang/test/ci/ci_utils.py index 8863e4b3d..9e0ed0b2b 100644 --- a/python/sglang/test/ci/ci_utils.py +++ b/python/sglang/test/ci/ci_utils.py @@ -223,10 +223,18 @@ def run_unittest_files( errors="ignore", # Ignore non-UTF-8 bytes to prevent UnicodeDecodeError ) output_lines = [] - for line in process.stdout: - logger.info(line.rstrip()) - output_lines.append(line) + + def read_output(): + for line in process.stdout: + logger.info(line.rstrip()) + output_lines.append(line) + + # Read stdout on a background thread so the main thread won't block on EOF. + reader_thread = threading.Thread(target=read_output, daemon=True) + reader_thread.start() process.wait() + # Bounded wait for the reader to finish. + reader_thread.join(timeout=60) else: process = subprocess.Popen(cmd, stdout=None, stderr=None) process.wait()