mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
test(lifecycle): scope shutdown budget assertion
This commit is contained in:
@@ -396,13 +396,20 @@ def test_plugin_settlement_cannot_bypass_task_registry_shutdown_budget(
|
|||||||
lifecycle.init_extra.side_effect = settle_plugins
|
lifecycle.init_extra.side_effect = settle_plugins
|
||||||
|
|
||||||
async def run_lifespan() -> None:
|
async def run_lifespan() -> None:
|
||||||
"""确认 context 能由 TaskRegistry 的失败结果立即结束。"""
|
"""仅对关闭阶段计时,避免覆盖率启动开销污染停机预算断言。"""
|
||||||
async with lifecycle.lifespan(FastAPI()):
|
lifespan_context = lifecycle.lifespan(FastAPI())
|
||||||
|
await lifespan_context.__aenter__()
|
||||||
|
try:
|
||||||
await started.wait()
|
await started.wait()
|
||||||
release.set()
|
await asyncio.wait_for(
|
||||||
await asyncio.sleep(0)
|
lifespan_context.__aexit__(None, None, None),
|
||||||
|
timeout=0.5,
|
||||||
|
)
|
||||||
|
finally:
|
||||||
|
release.set()
|
||||||
|
await asyncio.sleep(0)
|
||||||
|
|
||||||
asyncio.run(asyncio.wait_for(run_lifespan(), timeout=0.5))
|
asyncio.run(run_lifespan())
|
||||||
|
|
||||||
shutdown.assert_awaited_once_with(timeout_seconds=30.0)
|
shutdown.assert_awaited_once_with(timeout_seconds=30.0)
|
||||||
for name, step in shutdown_steps.items():
|
for name, step in shutdown_steps.items():
|
||||||
|
|||||||
Reference in New Issue
Block a user