feat: WS 每 IP 并发连接上限(默认10,(租户,IP) 键,finally 释放)

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-10-12 20:54:28 +08:00
parent fd0f49870c
commit 54a65ed7da
5 changed files with 173 additions and 8 deletions
+10
View File
@@ -64,6 +64,16 @@ def _reset_rate_limit():
_reset_for_test()
@pytest.fixture(autouse=True)
def _reset_conn_limiter():
"""Task 8: 同上——WS 连接限流器的模块级单例计数前后复位,跨测试不泄漏
(TestClient 所有连接同落 ip="testclient",不复位会互相顶名额)。"""
from app.engine.services.conn_limiter import _reset_for_test
_reset_for_test()
yield
_reset_for_test()
@pytest.fixture
def jiancai_runtime():
"""直连测试用的 jiancai TenantRuntime(Task 6: manager 的 runtime 必填)。