Merge pull request #273 from kevin9327/fix/test-endpoint-cold-cache

fix(settings): 端点清单缓存未预热时端点测速 500
This commit is contained in:
wshy
2026-09-09 09:04:11 +08:00
committed by GitHub
2 changed files with 51 additions and 1 deletions
+3 -1
View File
@@ -1666,7 +1666,9 @@ async def test_endpoint(req: TestEndpointIn) -> dict:
import statistics
base = req.url.rstrip("/")
rounds = max(1, min(10, req.rounds or _endpoints_cache.get("data", {}).get("testRounds", 5)))
# 缓存初值的 "data" 是 None(键存在, get 的默认值不生效), 端点清单未预热时要兜底
manifest = _endpoints_cache.get("data") or {}
rounds = max(1, min(10, req.rounds or manifest.get("testRounds", 5)))
health_url = base + "/health"
latencies: list[float] = []