open-webui/backend/open_webui
Juan Calderon-Perez 51246bcb31
perf(backend): offload blocking calls in async paths to threads (#26381)
Audit of asyncio.sleep vs time.sleep and event-loop-blocking calls:

- utils/plugin.py: run pip `install_frontmatter_requirements`
  (subprocess.check_call) via asyncio.to_thread in load_tool_module_by_id,
  load_function_module_by_id, and install_tool_and_function_dependencies.
- retrieval/utils.py: move the synchronous SSRF-guarded requests probe and
  loader.load() in get_content_from_url into a sync helper run via
  asyncio.to_thread.
- routers/audio.py: write uploaded audio to disk off the event loop in
  transcription().
- routers/pipelines.py: write uploaded pipeline file off the event loop in
  upload_pipeline().

The existing time.sleep call sites are all in genuinely synchronous
functions (sync requests/DB drivers/daemon threads) with async
counterparts that already use asyncio.sleep, so no time.sleep -> asyncio.sleep
changes were needed.


Claude-Session: https://claude.ai/code/session_01LXR5bYfsfSS42RGHQZu2Ta

Co-authored-by: Claude <noreply@anthropic.com>
2026-06-29 10:42:26 -05:00
..
data refac: mv backend files to /open_webui dir 2024-09-04 16:54:48 +02:00
internal refac 2026-06-17 02:52:35 +02:00
migrations refac 2026-06-29 05:49:49 -05:00
models refac 2026-06-29 06:08:31 -05:00
retrieval perf(backend): offload blocking calls in async paths to threads (#26381) 2026-06-29 10:42:26 -05:00
routers perf(backend): offload blocking calls in async paths to threads (#26381) 2026-06-29 10:42:26 -05:00
socket refac 2026-06-29 03:58:00 -05:00
static chore: format 2026-06-01 14:10:40 -07:00
storage refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00
tools refac 2026-06-29 06:01:05 -05:00
utils perf(backend): offload blocking calls in async paths to threads (#26381) 2026-06-29 10:42:26 -05:00
__init__.py refac 2026-06-17 03:01:11 +02:00
alembic.ini fix: Alembic CLI commands from failing 2025-08-15 04:17:47 -04:00
config.py refac 2026-06-29 05:46:47 -05:00
constants.py refac 2026-06-29 05:46:51 -05:00
env.py refac 2026-06-29 03:42:36 -05:00
events.py refac 2026-06-25 15:56:10 +01:00
functions.py fix: emit [DONE] for AsyncGenerator pipe returns (#24763) 2026-05-19 22:07:56 +04:00
main.py feat: forward client User-Agent to model backends via {{USER_AGENT}} placeholder (#26333) 2026-06-29 05:58:19 -05:00
tasks.py refac: modernize type annotations (PEP 604 / PEP 585) 2026-05-12 17:10:15 +09:00