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.

Do not let the gap worker lock test deadlock its own worker (#15091)

Daniel Hanf49cbdf5355e
diff --git a/studio/backend/tests/test_conversation_archive.py b/studio/backend/tests/test_conversation_archive.py
index e8b61b67b72..35f124f423a 100644
--- a/studio/backend/tests/test_conversation_archive.py
+++ b/studio/backend/tests/test_conversation_archive.py
@@ -2082,10 +2082,18 @@ def test_the_gap_worker_never_queues_behind_another_embedder_user(conn, monkeypa
"backend_build": embeddings._backend_lock,
}[held]
+ encoded = threading.Event()
+
+ # Queue behind the other user's lock, then encode outside it. Holding it across real() made
+ # the worker take the same non-reentrant lock again inside encode, so once the gap reopened it
+ # hung for good and stalled the next test on that xdist worker until pytest-timeout fired.
def locked(texts, **kwargs):
with lock:
time.sleep(0.5)
+ try:
return real(texts, **kwargs)
+ finally:
+ encoded.set()
monkeypatch.setattr(embeddings, "encode_with_identity", locked)
monkeypatch.setattr(conversation_archive, "_PAUSE_JOIN_S", 30.0)
@@ -2097,6 +2105,7 @@ def test_the_gap_worker_never_queues_behind_another_embedder_user(conn, monkeypa
with conversation_archive.inference_running():
waited = time.monotonic() - started
assert waited < 1.0
+ assert encoded.wait(timeout = 30), "the gap worker never finished the encode it queued"
@pytest.mark.parametrize("busy", ["training", "diffusion_training", "media", "unreadable"])