feat: 添加多线程架构支持并优化性能

实现线程管理器以支持高并发场景,添加GIL-free模式提升Python 3.14下的多线程性能
新增B站API集成和本地文件服务器功能,改进镜像插件支持GIF处理
更新文档说明多线程架构和GIL-free模式的使用方法
This commit is contained in:
2026-03-01 16:01:51 +08:00
parent 734c112ee4
commit ff4a4d92a5
20 changed files with 2071 additions and 317 deletions

18
main.py
View File

@@ -15,11 +15,12 @@ from core.utils.logger import logger
# 核心模块导入
from core.ws import WS
from core.managers import plugin_manager, matcher, permission_manager, reverse_ws_manager
from core.managers import plugin_manager, matcher, permission_manager, reverse_ws_manager, thread_manager
from core.managers.redis_manager import redis_manager
from core.managers.browser_manager import browser_manager
from core.utils.executor import run_in_thread_pool, initialize_executor
from core.config_loader import global_config as config
from core.services.local_file_server import start_local_file_server, stop_local_file_server
@@ -151,6 +152,12 @@ async def main():
))
logger.success(f"反向 WebSocket 服务端已启动: ws://{config.reverse_ws.host}:{config.reverse_ws.port}")
# 启动本地文件服务器(如果启用)
if config.local_file_server.enabled:
logger.info("正在启动本地文件服务器...")
asyncio.create_task(start_local_file_server())
logger.success(f"本地文件服务器已启动: http://{config.local_file_server.host}:{config.local_file_server.port}")
# 启动文件监控
# 监控 plugins 目录
plugin_path = os.path.join(os.path.dirname(__file__), "plugins")
@@ -198,7 +205,14 @@ async def main():
# 关闭反向 WebSocket 服务端
if config.reverse_ws.enabled and reverse_ws_manager.server:
await reverse_ws_manager.stop()
# 关闭本地文件服务器
if config.local_file_server.enabled:
await stop_local_file_server()
# 关闭线程管理器
thread_manager.shutdown()
# 关闭浏览器管理器
await browser_manager.shutdown()