mirror of
https://github.com/open-webui/open-webui.git
synced 2026-06-04 07:47:12 -05:00
[PR #20528] [CLOSED] fix: prevent event loop blocking during file processing #96695
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/20528
Author: @jk-f5
Created: 1/9/2026
Status: ❌ Closed
Base:
dev← Head:fix/async-embedding-event-loop📝 Commits (1)
fe6ff8dfix: prevent event loop blocking during file processing by converting to async📊 Changes
2 files changed (+29 additions, -32 deletions)
View changed files
📝
backend/open_webui/routers/files.py(+12 -12)📝
backend/open_webui/routers/retrieval.py(+17 -20)📄 Description
Description
Fixes event loop blocking during file upload and document processing that causes liveness probe failures and pod restarts in Kubernetes deployments.
Problem
save_docs_to_vector_db()usedasyncio.run()to call the async embedding function, which blocks the entire event loop. During large file uploads, this prevents uvicorn from responding to any requests (including health checks), causing Kubernetes to kill pods.Additionally, CPU-bound text splitting operations (
split_documents()) can block the event loop for extended periods on large files.Solution
save_docs_to_vector_db()andprocess_file()to async functionsasyncio.run(embedding_function(...))withawait embedding_function(...)run_in_threadpool()to prevent blockingfiles.pyandretrieval.pyto await the async functions, including the inner_process_handlerfunctionTesting
I initially implemented this from branching off the v0.6.43 tag. I've been running this in our prod environment for about a week. It has been modified further due to changes on the dev branch to apply cleanly and account for upstream changes.
AI disclaimer
AI wrote some of this MR description and reviewed the code for this MR.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.