From b58435ef3a23c2d89f5ba1c89d9c56268114aef1 Mon Sep 17 00:00:00 2001 From: DiweiSun <105627594+DiweiSun@users.noreply.github.com> Date: Fri, 25 Apr 2025 14:16:28 +0800 Subject: [PATCH 1/2] add runtime check for server setup in UT cases --- python/sglang/test/test_utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/python/sglang/test/test_utils.py b/python/sglang/test/test_utils.py index ed95ccd7081d..e4ef99de7ea8 100644 --- a/python/sglang/test/test_utils.py +++ b/python/sglang/test/test_utils.py @@ -447,6 +447,16 @@ def popen_launch_server( start_time = time.time() with requests.Session() as session: while time.time() - start_time < timeout: + + # check if server process has crashe/exited + return_code = process.poll() + if return_code is not None: + # Server failed to start (non-zero exit code) or crashed + raise Exception( + f"Server process exited with code {return_code}. " + "Check server logs for errors." + ) + try: headers = { "Content-Type": "application/json; charset=utf-8", From c5707afd087462e5a3fa15d7d7aa5056928643bc Mon Sep 17 00:00:00 2001 From: diwei sun Date: Sun, 11 May 2025 19:42:20 -0700 Subject: [PATCH 2/2] fix format --- python/sglang/test/test_utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/sglang/test/test_utils.py b/python/sglang/test/test_utils.py index e4ef99de7ea8..1ce73715d884 100644 --- a/python/sglang/test/test_utils.py +++ b/python/sglang/test/test_utils.py @@ -447,16 +447,16 @@ def popen_launch_server( start_time = time.time() with requests.Session() as session: while time.time() - start_time < timeout: - + # check if server process has crashe/exited - return_code = process.poll() + return_code = process.poll() if return_code is not None: # Server failed to start (non-zero exit code) or crashed raise Exception( f"Server process exited with code {return_code}. " "Check server logs for errors." ) - + try: headers = { "Content-Type": "application/json; charset=utf-8",