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.

Wait on the pooled fetch itself in the closed-request browser test (#12835)

Daniel Han42719e4824b4
diff --git a/studio/backend/tests/test_browser_routes.py b/studio/backend/tests/test_browser_routes.py
index 35333d5eb06..3300e9428b2 100644
--- a/studio/backend/tests/test_browser_routes.py
+++ b/studio/backend/tests/test_browser_routes.py
@@ -278,17 +278,23 @@ def test_fetches_run_in_their_own_pool(monkeypatch):
def test_a_closed_request_cancels_the_fetch(monkeypatch):
seen = {}
+ # The route returns 499 without waiting for its pool task, so wait on the fetch itself. Draining
+ # the pool with no-ops was not enough: idle workers finish those while the fetch's own thread
+ # has not yet recorded what it saw, and a loaded CI worker read an empty dict (KeyError).
+ finished = threading.Event()
def slow_fetch(url, **kwargs):
- seen["cancelled"] = kwargs["cancel_event"].wait(5)
+ try:
+ seen["cancelled"] = kwargs["cancel_event"].wait(5)
+ finally:
+ finished.set()
return "cancelled", "", ""
monkeypatch.setattr(browser_mod, "_fetch_url_raw", slow_fetch)
with pytest.raises(HTTPException) as caught:
_call(_Client(disconnected = True))
assert caught.value.status_code == 499
- for _ in range(browser_mod._FETCH_POOL._max_workers):
- browser_mod._FETCH_POOL.submit(lambda: None).result(5)
+ assert finished.wait(10), "the pooled fetch never ran"
assert seen["cancelled"] is True