Let DELETE /datasets to a dedicated thread to avoid blocking other APIs (#17796)

This commit is contained in:
Wang Qi
2026-08-04 16:19:56 +08:00
committed by GitHub
parent 8c8c1e7df7
commit 7e67b71b81

View File

@@ -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.