mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 19:39:42 +08:00
Batch-uploading files stalled every other request — chat WebSockets included — for the whole duration of the batch. Two blocking paths, both in an async context: * ``_save_uploaded_files`` blocks end to end (a chunked write of every uploaded byte, zip extraction, plus a synchronous HTTP upload per file when PocketBase is on) and was called inline from the upload and create-KB routes; * the follow-up work runs in a FastAPI ``BackgroundTasks`` entry declared ``async def``, which starlette awaits ON the loop — only *sync* callables reach its threadpool — so the staging pass (a full-content hash per file plus a copy) and the per-file re-hash blocked there too. Each of those moves to a worker thread. Reading ``UploadFile.file`` off-loop is safe: it is the plain SpooledTemporaryFile, never the async API. The provider index itself already ran through an executor, and the remaining small JSON writes are left inline rather than paying a thread hop each.