mirror of
https://github.com/open-webui/open-webui
synced 2025-04-24 16:32:11 +00:00
refac
This commit is contained in:
parent
5f84145a2d
commit
d055e1f888
@ -1,5 +1,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import socketio
|
import socketio
|
||||||
|
import logging
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from open_webui.apps.webui.models.users import Users
|
from open_webui.apps.webui.models.users import Users
|
||||||
@ -11,6 +13,16 @@ from open_webui.env import (
|
|||||||
from open_webui.utils.utils import decode_token
|
from open_webui.utils.utils import decode_token
|
||||||
from open_webui.apps.socket.utils import RedisDict
|
from open_webui.apps.socket.utils import RedisDict
|
||||||
|
|
||||||
|
from open_webui.env import (
|
||||||
|
GLOBAL_LOG_LEVEL,
|
||||||
|
SRC_LOG_LEVELS,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
logging.basicConfig(stream=sys.stdout, level=GLOBAL_LOG_LEVEL)
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
log.setLevel(SRC_LOG_LEVELS["SOCKET"])
|
||||||
|
|
||||||
|
|
||||||
if WEBSOCKET_MANAGER == "redis":
|
if WEBSOCKET_MANAGER == "redis":
|
||||||
mgr = socketio.AsyncRedisManager(WEBSOCKET_REDIS_URL)
|
mgr = socketio.AsyncRedisManager(WEBSOCKET_REDIS_URL)
|
||||||
@ -57,7 +69,7 @@ TIMEOUT_DURATION = 3
|
|||||||
async def periodic_usage_pool_cleanup():
|
async def periodic_usage_pool_cleanup():
|
||||||
while True:
|
while True:
|
||||||
now = int(time.time())
|
now = int(time.time())
|
||||||
print("Cleaning up usage pool", now)
|
log.debug("Cleaning up usage pool", now)
|
||||||
for model_id, connections in list(USAGE_POOL.items()):
|
for model_id, connections in list(USAGE_POOL.items()):
|
||||||
# Creating a list of sids to remove if they have timed out
|
# Creating a list of sids to remove if they have timed out
|
||||||
expired_sids = [
|
expired_sids = [
|
||||||
|
@ -84,6 +84,7 @@ log_sources = [
|
|||||||
"OPENAI",
|
"OPENAI",
|
||||||
"RAG",
|
"RAG",
|
||||||
"WEBHOOK",
|
"WEBHOOK",
|
||||||
|
"SOCKET",
|
||||||
]
|
]
|
||||||
|
|
||||||
SRC_LOG_LEVELS = {}
|
SRC_LOG_LEVELS = {}
|
||||||
|
Loading…
Reference in New Issue
Block a user