From 41d1ccd39c5dbddb122eb8910bd0fcdf7996d19e Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Sat, 10 Jan 2026 12:34:12 +0100 Subject: [PATCH] Update channels.py (#20546) --- backend/open_webui/routers/channels.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/routers/channels.py b/backend/open_webui/routers/channels.py index 777f5e74ea..4e697142bf 100644 --- a/backend/open_webui/routers/channels.py +++ b/backend/open_webui/routers/channels.py @@ -1256,15 +1256,17 @@ async def post_new_message( active_user_ids = get_user_ids_from_room(f"channel:{channel.id}") + # NOTE: We intentionally do NOT pass db to background_handler. + # Background tasks should manage their own short-lived sessions to avoid + # holding database connections during slow operations (e.g., LLM calls). async def background_handler(): - await model_response_handler(request, channel, message, user, db) + await model_response_handler(request, channel, message, user) await send_notification( request.app.state.WEBUI_NAME, request.app.state.config.WEBUI_URL, channel, message, active_user_ids, - db=db, ) background_tasks.add_task(background_handler)