fix(tests): prevent xdist worker OOM from leaked tarpit asyncio task
asyncio_default_fixture_loop_scope was 'module', so all async tests in a module share one event loop. test_lifespan_startup_and_shutdown patched log_ingestion_worker/log_collector_worker/attacker_profile_worker but not tarpit_watcher_worker — the real while-True coroutine was created as an asyncio task on the shared loop and never cancelled. The xdist worker ran for 4+ hours (confirmed via py-spy + etime=04:48) consuming 15+ GB before OOM-kill. Fixes: - Patch tarpit_watcher_worker in both TestLifespan tests - Change asyncio_default_fixture_loop_scope to 'function' so each test gets its own loop; tasks cannot outlive their test - Add loop_scope='module' to precision_engine which legitimately needs a module-scoped event loop
This commit is contained in:
@@ -102,7 +102,7 @@ def compiled_rules() -> list[CompiledRule]:
|
||||
return _load_compiled_rules()
|
||||
|
||||
|
||||
@pytest_asyncio.fixture(scope="module")
|
||||
@pytest_asyncio.fixture(scope="module", loop_scope="module")
|
||||
async def precision_engine(
|
||||
compiled_rules: list[CompiledRule],
|
||||
) -> RuleEngine:
|
||||
|
||||
Reference in New Issue
Block a user