From 7e67b71b81e5f2bdb15533bc66ab03d2442332d9 Mon Sep 17 00:00:00 2001 From: Wang Qi Date: Tue, 4 Aug 2026 16:19:56 +0800 Subject: [PATCH] Let DELETE /datasets to a dedicated thread to avoid blocking other APIs (#17796) --- api/apps/services/dataset_api_service.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/api/apps/services/dataset_api_service.py b/api/apps/services/dataset_api_service.py index 073c48c05b..e143c2a979 100644 --- a/api/apps/services/dataset_api_service.py +++ b/api/apps/services/dataset_api_service.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import asyncio import logging import json import os @@ -143,7 +144,7 @@ async def create_dataset(tenant_id: str, req: dict): return True, response_data -async def delete_datasets(tenant_id: str, ids: list = None, delete_all: bool = False): +def _delete_datasets_sync(tenant_id: str, ids: list = None, delete_all: bool = False): """ Delete datasets. @@ -220,6 +221,10 @@ async def delete_datasets(tenant_id: str, ids: list = None, delete_all: bool = F return True, {"success_count": success_count, "errors": errors[:5]} +async def delete_datasets(tenant_id: str, ids: list = None, delete_all: bool = False): + return await asyncio.to_thread(_delete_datasets_sync, tenant_id, ids, delete_all) + + def get_dataset(dataset_id: str, tenant_id: str): """ Get a single dataset.