From e19406cdd7672b5328c489541de5fc9e69243829 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Tue, 24 Sep 2024 17:43:43 +0200 Subject: [PATCH] fix --- backend/open_webui/apps/socket/main.py | 5 ----- backend/open_webui/main.py | 7 +++++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/backend/open_webui/apps/socket/main.py b/backend/open_webui/apps/socket/main.py index 09eb91a6e..fca268a6b 100644 --- a/backend/open_webui/apps/socket/main.py +++ b/backend/open_webui/apps/socket/main.py @@ -90,14 +90,9 @@ async def periodic_usage_pool_cleanup(): await asyncio.sleep(TIMEOUT_DURATION) -async def on_startup(): - asyncio.create_task(periodic_usage_pool_cleanup()) - - app = socketio.ASGIApp( sio, socketio_path="/ws/socket.io", - on_startup=on_startup(), ) diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index 2ded77f2f..d190b916e 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -8,6 +8,8 @@ import shutil import sys import time import uuid +import asyncio + from contextlib import asynccontextmanager from typing import Optional @@ -31,7 +33,7 @@ from open_webui.apps.openai.main import ( from open_webui.apps.openai.main import get_all_models as get_openai_models from open_webui.apps.rag.main import app as rag_app from open_webui.apps.rag.utils import get_rag_context, rag_template -from open_webui.apps.socket.main import app as socket_app +from open_webui.apps.socket.main import app as socket_app, periodic_usage_pool_cleanup from open_webui.apps.socket.main import get_event_call, get_event_emitter from open_webui.apps.webui.internal.db import Session from open_webui.apps.webui.main import app as webui_app @@ -184,6 +186,8 @@ https://github.com/open-webui/open-webui @asynccontextmanager async def lifespan(app: FastAPI): run_migrations() + + asyncio.create_task(periodic_usage_pool_cleanup()) yield @@ -851,7 +855,6 @@ async def inspect_websocket(request: Request, call_next): app.mount("/ws", socket_app) - app.mount("/ollama", ollama_app) app.mount("/openai", openai_app)