refactor: own coalescer flush lifecycle

This commit is contained in:
jxxghp
2026-08-24 03:11:49 +08:00
parent e1230c0277
commit e768eb46fe
9 changed files with 71 additions and 7 deletions
+19
View File
@@ -1120,6 +1120,16 @@ def _patch_module_shutdown_dependencies(monkeypatch) -> dict:
monkeypatch.setattr(modules_initializer, name, dependency)
dependencies[name] = dependency
close_image_proxy_block_log_coalescer = AsyncMock()
monkeypatch.setattr(
modules_initializer,
"close_image_proxy_block_log_coalescer",
close_image_proxy_block_log_coalescer,
)
dependencies["close_image_proxy_block_log_coalescer"] = (
close_image_proxy_block_log_coalescer
)
stop_managed_resources = AsyncMock()
monkeypatch.setattr(
modules_initializer,
@@ -1158,6 +1168,15 @@ def test_browser_sessions_close_before_managed_resources(monkeypatch) -> None:
assert calls == ["browser", "resources"]
def test_module_shutdown_waits_for_image_proxy_log_coalescer(monkeypatch) -> None:
"""模块关闭必须等待图片安全日志的在途聚合任务收口。"""
dependencies = _patch_module_shutdown_dependencies(monkeypatch)
asyncio.run(modules_initializer.stop_modules())
dependencies["close_image_proxy_block_log_coalescer"].assert_awaited_once_with()
def test_shared_http_close_waits_for_real_lru_eviction(monkeypatch):
"""最终 HTTP 关闭必须等待真实 LRU 淘汰任务并消费其异常"""