Unverified Commit de89ef49 authored by Liangsheng Yin's avatar Liangsheng Yin Committed by GitHub
Browse files

[CI]] Tee server logs to both file and stdout/stderr using PIPE (#11185)

parent b00a0c78
...@@ -9,6 +9,7 @@ import os ...@@ -9,6 +9,7 @@ import os
import random import random
import re import re
import subprocess import subprocess
import sys
import threading import threading
import time import time
import unittest import unittest
...@@ -566,11 +567,30 @@ def popen_launch_server( ...@@ -566,11 +567,30 @@ def popen_launch_server(
if return_stdout_stderr: if return_stdout_stderr:
process = subprocess.Popen( process = subprocess.Popen(
command, command,
stdout=return_stdout_stderr[0], stdout=subprocess.PIPE,
stderr=return_stdout_stderr[1], stderr=subprocess.PIPE,
env=env, env=env,
text=True, text=True,
bufsize=1,
) )
def _dump(src, sinks):
for line in iter(src.readline, ""):
for sink in sinks:
sink.write(line)
sink.flush()
src.close()
threading.Thread(
target=_dump,
args=(process.stdout, [return_stdout_stderr[0], sys.stdout]),
daemon=True,
).start()
threading.Thread(
target=_dump,
args=(process.stderr, [return_stdout_stderr[1], sys.stderr]),
daemon=True,
).start()
else: else:
process = subprocess.Popen(command, stdout=None, stderr=None, env=env) process = subprocess.Popen(command, stdout=None, stderr=None, env=env)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment