This commit is contained in:
Timothy J. Baek 2024-09-24 17:43:43 +02:00
parent 71743b25fe
commit e19406cdd7
2 changed files with 5 additions and 7 deletions

View File

@ -90,14 +90,9 @@ async def periodic_usage_pool_cleanup():
await asyncio.sleep(TIMEOUT_DURATION) await asyncio.sleep(TIMEOUT_DURATION)
async def on_startup():
asyncio.create_task(periodic_usage_pool_cleanup())
app = socketio.ASGIApp( app = socketio.ASGIApp(
sio, sio,
socketio_path="/ws/socket.io", socketio_path="/ws/socket.io",
on_startup=on_startup(),
) )

View File

@ -8,6 +8,8 @@ import shutil
import sys import sys
import time import time
import uuid import uuid
import asyncio
from contextlib import asynccontextmanager from contextlib import asynccontextmanager
from typing import Optional 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.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.main import app as rag_app
from open_webui.apps.rag.utils import get_rag_context, rag_template 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.socket.main import get_event_call, get_event_emitter
from open_webui.apps.webui.internal.db import Session from open_webui.apps.webui.internal.db import Session
from open_webui.apps.webui.main import app as webui_app from open_webui.apps.webui.main import app as webui_app
@ -184,6 +186,8 @@ https://github.com/open-webui/open-webui
@asynccontextmanager @asynccontextmanager
async def lifespan(app: FastAPI): async def lifespan(app: FastAPI):
run_migrations() run_migrations()
asyncio.create_task(periodic_usage_pool_cleanup())
yield yield
@ -851,7 +855,6 @@ async def inspect_websocket(request: Request, call_next):
app.mount("/ws", socket_app) app.mount("/ws", socket_app)
app.mount("/ollama", ollama_app) app.mount("/ollama", ollama_app)
app.mount("/openai", openai_app) app.mount("/openai", openai_app)