Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions python/sglang/test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading