graceful exit

This commit is contained in:
CakeCN
2025-09-13 15:30:18 +08:00
parent 2087776e40
commit b1e132db8d
3 changed files with 50 additions and 3 deletions

View File

@@ -9,6 +9,7 @@ from flask_pymongo import PyMongo
from qcloud_cos import CosConfig
from qcloud_cos import CosS3Client
from typing import Optional
mongo = PyMongo()
@@ -76,4 +77,15 @@ def register_namespaces(app):
# 延迟导入以避免循环
from .sockets.namespaces import VSCodeNamespace, AgentNamespace
socketio.on_namespace(VSCodeNamespace("/vscode"))
socketio.on_namespace(AgentNamespace("/agent"))
socketio.on_namespace(AgentNamespace("/agent"))
def close_extensions():
# 按“最可能阻塞”的优先级依次停止
try:
if user_uuid2chatmanager:
for uuid in user_uuid2chatmanager:
user_uuid2chatmanager[uuid].disconnect(uuid)
except Exception as e:
print("Failed to shutdown scheduler: %s", e)