From 4f92e63c99fa334061466268d3730080ec9328ef Mon Sep 17 00:00:00 2001 From: Cheng Wan <54331508+ch-wan@users.noreply.github.com> Date: Thu, 28 May 2026 16:26:17 -0700 Subject: [PATCH] Let unittest._ShouldStop propagate through retry() so subTest+failfast works (#26616) Co-authored-by: Claude Opus 4.7 (1M context) --- python/sglang/srt/utils/common.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/python/sglang/srt/utils/common.py b/python/sglang/srt/utils/common.py index c21ae98b1..de149625a 100644 --- a/python/sglang/srt/utils/common.py +++ b/python/sglang/srt/utils/common.py @@ -72,6 +72,7 @@ from typing import ( Union, ) from unittest import SkipTest +from unittest.case import _ShouldStop from urllib.parse import unquote, urlparse import numpy as np @@ -2771,6 +2772,13 @@ def retry( except SkipTest: # Do NOT retry skipped tests - used in CI and unittest raise + except _ShouldStop: + # `unittest.case._ShouldStop` is raised by `subTest.__exit__` + # when a subtest fails/skips and `result.failfast` is True + # (CI invokes `python3 file.py -f`). It signals the outer + # `testPartExecutor` to stop the test method cleanly; do + # NOT retry, just propagate so unittest handles it. + raise except Exception as e: traceback.print_exc()