From 22cfb3c673cbfa4a6bce26fde8e2e2754ce4963b Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Mon, 13 Apr 2026 13:26:13 -0500 Subject: [PATCH] refac --- backend/open_webui/routers/retrieval.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/routers/retrieval.py b/backend/open_webui/routers/retrieval.py index 1e1beac4fa..4214eb6851 100644 --- a/backend/open_webui/routers/retrieval.py +++ b/backend/open_webui/routers/retrieval.py @@ -1698,7 +1698,12 @@ async def process_file( # External embedding API takes time (5-60s+). # Subsequent updates use fresh async sessions. - result = save_docs_to_vector_db( + # NOTE: save_docs_to_vector_db is a sync function that + # calls asyncio.run_coroutine_threadsafe(..., main_loop).result() + # which blocks the calling thread. We MUST run it in a + # worker thread to avoid deadlocking the event loop. + result = await run_in_threadpool( + save_docs_to_vector_db, request, docs=docs, collection_name=collection_name,