feat: 添加性能优化和架构文档,更新依赖和核心模块
refactor(browser_manager): 实现页面池机制以提升性能 refactor(image_manager): 添加模板缓存并集成页面池 refactor(bili_parser): 迁移到异步HTTP请求并实现会话复用 docs: 新增性能优化、架构设计和最佳实践文档 chore: 更新requirements.txt添加新依赖
This commit is contained in:
19
main.py
19
main.py
@@ -10,6 +10,21 @@ import time
|
||||
from watchdog.observers import Observer
|
||||
from watchdog.events import FileSystemEventHandler
|
||||
|
||||
# 尝试使用高性能事件循环
|
||||
try:
|
||||
if sys.platform == 'win32':
|
||||
# winloop 与 Playwright 存在兼容性问题 (不支持 startupinfo),暂时禁用
|
||||
# import winloop
|
||||
# asyncio.set_event_loop_policy(winloop.EventLoopPolicy())
|
||||
# print("已启用 winloop 高性能事件循环")
|
||||
print("Windows 平台检测到 Playwright,已自动禁用 winloop 以确保兼容性")
|
||||
else:
|
||||
import uvloop
|
||||
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
|
||||
print("已启用 uvloop 高性能事件循环")
|
||||
except ImportError:
|
||||
print("未检测到高性能事件循环库 (uvloop/winloop),将使用默认事件循环")
|
||||
|
||||
# 初始化日志系统,必须在其他 core 模块导入之前执行
|
||||
from core.utils.logger import logger
|
||||
|
||||
@@ -118,8 +133,8 @@ async def main():
|
||||
# 初始化管理员管理器
|
||||
await admin_manager.initialize()
|
||||
|
||||
# 初始化浏览器管理器
|
||||
await browser_manager.initialize()
|
||||
# 初始化浏览器管理器 (使用页面池)
|
||||
await browser_manager.init_pool(size=3)
|
||||
|
||||
# 启动文件监控
|
||||
# 监控 plugins 目录
|
||||
|
||||
Reference in New Issue
Block a user