Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio tests: drain the background sandbox mover between tests (#15830)

Daniel Han36d3c108631d
diff --git a/studio/backend/tests/conftest.py b/studio/backend/tests/conftest.py
index 9593578f614..ae4b26e0188 100644
--- a/studio/backend/tests/conftest.py
+++ b/studio/backend/tests/conftest.py
@@ -373,6 +373,26 @@ def _isolate_studio_home(_studio_home_root, monkeypatch):
monkeypatch.setattr(module, "_schema_ready", set())
+def _drain_sandbox_movers(timeout: float = 30.0) -> None:
+ import threading
+
+ from .thread_drain import join_when_started
+ for thread in threading.enumerate():
+ if thread.name == "sandbox-migrate" and not join_when_started(thread, timeout = timeout):
+ raise RuntimeError("a background sandbox migration did not finish within 30s")
+
+
[email protected](autouse = True)
+def _no_sandbox_mover_outlives_its_test(monkeypatch):
+ # get_sandbox_workdir starts a background mover that reads the legacy root from HOME when it gets
+ # scheduled, not when it starts: one left running moved the next test's legacy folder into the
+ # previous test's root. Requesting monkeypatch drains it before HOME is put back, so a late mover
+ # never reads the real home either.
+ _drain_sandbox_movers()
+ yield
+ _drain_sandbox_movers()
+
+
def pytest_configure(config):
config.addinivalue_line(
"markers",