[CI] Read subprocess stdout on a background thread to avoid EOF deadlock (#36673)

This commit is contained in:
pllimax
2026-08-29 01:11:02 +08:00
committed by GitHub
parent 8e04f66a70
commit 726665e08e
+11 -3
View File
@@ -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()