diff --git a/python/sglang/test/test_utils.py b/python/sglang/test/test_utils.py index 162706cbba..0e26b57ca3 100644 --- a/python/sglang/test/test_utils.py +++ b/python/sglang/test/test_utils.py @@ -2420,10 +2420,23 @@ class CustomTestCase(unittest.TestCase): max_retry = envs.SGLANG_TEST_MAX_RETRY.get() if max_retry is None: max_retry = 1 if is_in_ci() else 0 - retry( - lambda: super(CustomTestCase, self)._callTestMethod(method), - max_retry=max_retry, + # A server that dies mid-method fails every later request; abort the + # run rather than let clients back off and the method retry against it. + # Teardown kills the server only after this window closes. + process = getattr(self, "process", None) + stop = ( + start_subprocess_fail_fast_watcher([("server", process)]) + if isinstance(process, subprocess.Popen) + else None ) + try: + retry( + lambda: super(CustomTestCase, self)._callTestMethod(method), + max_retry=max_retry, + ) + finally: + if stop is not None: + stop.set() def setUp(self): print(