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: bound lifespan probe timeouts (#7234)

LearningCircuita65ff76f397f
diff --git a/tests/web/test_app_main_and_lifespan_shutdown_guards.py b/tests/web/test_app_main_and_lifespan_shutdown_guards.py
index 6d09425310..707590384a 100644
--- a/tests/web/test_app_main_and_lifespan_shutdown_guards.py
+++ b/tests/web/test_app_main_and_lifespan_shutdown_guards.py
@@ -49,6 +49,10 @@ from local_deep_research.web import fastapi_app
SRC_ROOT = Path(fastapi_app.__file__).resolve().parents[2]
+# Leave time to kill/reap the child and report the failure before pytest's
+# 180-second deadline terminates the whole worker.
+_BOOT_PROBE_TIMEOUT_SECONDS = 120
+
# ---------------------------------------------------------------------------
# main()'s HTTPS branch
@@ -321,13 +325,29 @@ def _run_boot_probe(mode: str, workdir: Path, extra_env=None) -> dict:
env["LDR_NEWS_SCHEDULER_ENABLED"] = "true"
env.update(extra_env or {})
- completed = subprocess.run(
- [sys.executable, str(script), mode, str(out)],
- env=env,
- capture_output=True,
- text=True,
- timeout=300,
- )
+ try:
+ completed = subprocess.run(
+ [sys.executable, str(script), mode, str(out)],
+ env=env,
+ capture_output=True,
+ text=True,
+ timeout=_BOOT_PROBE_TIMEOUT_SECONDS,
+ )
+ except subprocess.TimeoutExpired as exc:
+ stderr = exc.stderr or ""
+ if isinstance(stderr, bytes):
+ stderr = stderr.decode("utf-8", errors="replace")
+ # A child may write its JSON before hanging during interpreter exit.
+ # Its incomplete process lifecycle must still fail every guard check.
+ return {
+ "mode": mode,
+ "probe_returncode": None,
+ "probe_wrote_json": out.exists(),
+ "probe_stderr": f"Timed out after {exc.timeout}s\n{stderr[-3000:]}",
+ "shutdown_completed": False,
+ "health_status": None,
+ "trace": [],
+ }
# Deliberately NOT pytest.fail() here: a raise inside a fixture lands in
# pytest's separate ERRORS bucket, which is far easier to overlook than a
# FAILED. The probe's outcome is returned as DATA and asserted in the
diff --git a/tests/web/test_lifespan_startup_shutdown.py b/tests/web/test_lifespan_startup_shutdown.py
index 9ec87a4211..3141a9ad87 100644
--- a/tests/web/test_lifespan_startup_shutdown.py
+++ b/tests/web/test_lifespan_startup_shutdown.py
@@ -78,6 +78,10 @@ FASTAPI_APP_PATH = Path(fastapi_app.__file__).resolve()
SERVER_ENTRYPOINT_PATH = FASTAPI_APP_PATH.with_name("app.py")
SRC_ROOT = FASTAPI_APP_PATH.parents[2]
+# Leave time to kill/reap the child and report the failure before pytest's
+# 180-second deadline terminates the whole worker.
+_BOOT_PROBE_TIMEOUT_SECONDS = 120
+
# Threads the app is expected to own while it is up. Matched as substrings
# because APScheduler and the queue processor name their workers by
# target/index ("Thread-3 (_process_queue_loop)").
@@ -302,13 +306,24 @@ def _run_boot_probe(mode: str, workdir: Path) -> dict:
# PRODUCTION path, so this probe covers the processor's shutdown too.
env.pop("PYTEST_CURRENT_TEST", None)
- completed = subprocess.run(
- [sys.executable, str(script), mode, str(out)],
- env=env,
- capture_output=True,
- text=True,
- timeout=300,
- )
+ try:
+ completed = subprocess.run(
+ [sys.executable, str(script), mode, str(out)],
+ env=env,
+ capture_output=True,
+ text=True,
+ timeout=_BOOT_PROBE_TIMEOUT_SECONDS,
+ )
+ except subprocess.TimeoutExpired as exc:
+ stderr = exc.stderr or ""
+ if isinstance(stderr, bytes):
+ stderr = stderr.decode("utf-8", errors="replace")
+ pytest.fail(
+ f"boot probe ({mode}) timed out after {exc.timeout}s; "
+ "the app did not complete a startup/shutdown cycle.\n"
+ f"--- stderr ---\n{stderr[-3000:]}",
+ pytrace=False,
+ )
if completed.returncode != 0 or not out.exists():
pytest.fail(
f"boot probe ({mode}) failed with exit code "