diff --git a/python/sglang/test/test_utils.py b/python/sglang/test/test_utils.py index 1bacdadfff73..888a1fe937a1 100644 --- a/python/sglang/test/test_utils.py +++ b/python/sglang/test/test_utils.py @@ -546,21 +546,21 @@ def try_cached_model(model_repo: str): return model_dir if model_dir else model_repo -def popen_with_error_check(command: list[str], allow_exit: bool = False): - process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) +def popen_with_error_check(command: list[str]): + process = subprocess.Popen(command, stdout=None, stderr=None) def _run_and_check(): - stdout, stderr = process.communicate() + process.wait() - while process.poll() is None: - time.sleep(5) + if process.returncode == -9: + return - if not allow_exit or process.returncode != 0: + if process.returncode != 0: raise Exception( - f"{command} exited with code {process.returncode}\n{stdout=}\n{stderr=}" + f"{shlex.join(command)} exited with code {process.returncode}" ) - t = threading.Thread(target=_run_and_check) + t = threading.Thread(target=_run_and_check, daemon=True) t.start() return process