[PR #20910] [CLOSED] perf: unblock async event loop in pipelines router #25825

Closed
opened 2026-04-20 06:08:30 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/20910
Author: @sjhddh
Created: 1/23/2026
Status: Closed

Base: devHead: fix/pipelines-async-optimization


📝 Commits (1)

  • eb7c979 perf: unblock async event loop in pipelines router

📊 Changes

1 file changed (+25 additions, -14 deletions)

View changed files

📝 backend/open_webui/routers/pipelines.py (+25 -14)

📄 Description

Summary

Wrap synchronous requests calls with asyncio.to_thread() in the pipelines router to prevent blocking the FastAPI event loop during external pipeline API calls.

Problem

The pipelines router uses synchronous requests library calls inside async def endpoints. This blocks the entire Python event loop while waiting for external network I/O, preventing the server from handling other concurrent requests.

Solution

Wrap all blocking requests.get(), requests.post(), and requests.delete() calls with await asyncio.to_thread() to offload them to a thread pool. This allows the server to process other requests while waiting for pipeline operations to complete.

Changed

  • Wrapped blocking requests calls with asyncio.to_thread() in 7 endpoints:
    • upload_pipeline
    • add_pipeline
    • delete_pipeline
    • get_pipelines
    • get_pipeline_valves
    • get_pipeline_valves_spec
    • update_pipeline_valves

Fixed

  • Event loop blocking during external pipeline API calls

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/20910 **Author:** [@sjhddh](https://github.com/sjhddh) **Created:** 1/23/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix/pipelines-async-optimization` --- ### 📝 Commits (1) - [`eb7c979`](https://github.com/open-webui/open-webui/commit/eb7c9794c9dd5184b8cfc3c14df7651d6ab19038) perf: unblock async event loop in pipelines router ### 📊 Changes **1 file changed** (+25 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/routers/pipelines.py` (+25 -14) </details> ### 📄 Description ## Summary Wrap synchronous `requests` calls with `asyncio.to_thread()` in the pipelines router to prevent blocking the FastAPI event loop during external pipeline API calls. ## Problem The pipelines router uses synchronous `requests` library calls inside `async def` endpoints. This blocks the entire Python event loop while waiting for external network I/O, preventing the server from handling other concurrent requests. ## Solution Wrap all blocking `requests.get()`, `requests.post()`, and `requests.delete()` calls with `await asyncio.to_thread()` to offload them to a thread pool. This allows the server to process other requests while waiting for pipeline operations to complete. ### Changed - Wrapped blocking `requests` calls with `asyncio.to_thread()` in 7 endpoints: - `upload_pipeline` - `add_pipeline` - `delete_pipeline` - `get_pipelines` - `get_pipeline_valves` - `get_pipeline_valves_spec` - `update_pipeline_valves` ### Fixed - Event loop blocking during external pipeline API calls --- ### Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-20 06:08:30 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#25825