From aa5f5330d3abd1a3780cd7e883e75c80cf3273ef Mon Sep 17 00:00:00 2001 From: _00_ <131402327+rgaricano@users.noreply.github.com> Date: Tue, 19 Aug 2025 19:13:04 +0200 Subject: [PATCH] UPD: ExceptionGroup catch - update main.py ExceptionGroup catch - update main.py for catch and handle multiple concurrent exceptions Add caching for concurrent exceptions. Modified: - redis_task_command_listener --- backend/open_webui/main.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index d5b89c8d50..1781dd4204 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -578,8 +578,19 @@ async def lifespan(app: FastAPI): yield - if hasattr(app.state, "redis_task_command_listener"): - app.state.redis_task_command_listener.cancel() +# In the lifespan shutdown + if hasattr(app.state, "redis_task_command_listener"): + try: + app.state.redis_task_command_listener.cancel() + await app.state.redis_task_command_listener + except ExceptionGroup as eg: + log.error(f"Multiple errors during listener shutdown: {len(eg.exceptions)} exceptions") + for exc in eg.exceptions: + log.error(f"Shutdown error: {type(exc).__name__}: {exc}") + except asyncio.CancelledError: + pass # Expected during shutdown + except Exception as e: + log.error(f"Error during listener shutdown: {e}") app = FastAPI(