Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

test(close_base_llm): scale FD-growth test for Py 3.14 asyncio drift (#4224)

LearningCircuitc88c1ffe864d
diff --git a/tests/utilities/test_close_base_llm.py b/tests/utilities/test_close_base_llm.py
index 40158e5a9a..a0ba1122cf 100644
--- a/tests/utilities/test_close_base_llm.py
+++ b/tests/utilities/test_close_base_llm.py
@@ -368,8 +368,21 @@ class TestCloseBaseLLMRealHttpxAsync:
def test_no_fd_growth_across_repeated_close_cycles(self):
# Unit-level analogue of the PR's manual `lsof | grep -c eventpoll`
# smoke. A real per-cycle leak (~1 FD/iter as observed in #3816)
- # would push the delta well past the +2 slack we leave for ambient
- # logging/pytest churn.
+ # would push the delta well past the +8 slack.
+ #
+ # Sizing rationale (#4214 + #3816 follow-up):
+ # Each cycle invokes ``asyncio.run`` twice — once to construct the
+ # client in a (then-closed) loop A, once inside ``_close_base_llm``
+ # to spin loop B for ``aclose()``. On Py 3.14 these transient loops
+ # leave ambient FDs from selector/self-pipe lazy release. CI on the
+ # 5-iter version of this test showed a deterministic +3 delta (58
+ # of 58 recent failures), i.e. ~0.6 FDs/cycle steady-state — not
+ # absorbable by a single warmup since it's per-cycle, not init-only.
+ # At 20 iterations the expected ceiling is ~0.6 × 20 = ~12 in the
+ # worst case (observed ~3–4 locally); the +8 slack covers the
+ # typical range without masking a real per-iteration leak, which
+ # would land at ≥+20 (1 FD/iter, #3816 shape) + ambient → far
+ # above the threshold.
async def _make():
return httpx.AsyncClient()
@@ -387,22 +400,20 @@ class TestCloseBaseLLMRealHttpxAsync:
del llm, async_ollama, async_httpx
# Warmup: one cycle before measuring absorbs one-time init drift
- # (lazy imports, logging handlers, asyncio internals first-init)
- # that would otherwise eat the +2 steady-state slack. A real
- # per-iteration leak still shows as ≥+5 across the 5 measured iters.
+ # (lazy imports, logging handlers, asyncio internals first-init).
_one_cycle()
gc.collect()
before = _open_fd_count()
- for _ in range(5):
+ for _ in range(20):
_one_cycle()
gc.collect()
gc.collect()
after = _open_fd_count()
- assert after - before <= 2, (
+ assert after - before <= 8, (
f"FD count climbed across close cycles: "
f"before={before}, after={after}"
)