refactor(managers): 重构单例管理器实现并优化代码结构
feat(ws_pool): 新增 WebSocket 连接池实现 perf(json): 使用 orjson 替代标准 json 库提升性能 style: 清理未使用的导入和冗余代码 docs: 更新架构文档和开发规范 test: 添加 WebSocket 连接池测试用例 fix(plugins): 修复自动审批插件 API 调用参数格式
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import json
|
||||
import aiohttp
|
||||
from typing import Optional, Dict, Any, List
|
||||
from cachetools import TTLCache
|
||||
@@ -60,7 +59,7 @@ class GitHubParser(BaseParser):
|
||||
"""
|
||||
try:
|
||||
session = self.get_session()
|
||||
async with session.head(short_url, headers=self.HEADERS, allow_redirects=False, timeout=5) as response:
|
||||
async with session.head(short_url, headers=self.HEADERS, allow_redirects=False, timeout=aiohttp.ClientTimeout(total=5)) as response:
|
||||
if response.status == 302:
|
||||
return response.headers.get('Location')
|
||||
except Exception as e:
|
||||
@@ -86,7 +85,7 @@ class GitHubParser(BaseParser):
|
||||
api_url = f"https://api.github.com/repos/{owner}/{repo}"
|
||||
try:
|
||||
session = self.get_session()
|
||||
async with session.get(api_url, timeout=10) as response:
|
||||
async with session.get(api_url, timeout=aiohttp.ClientTimeout(total=10)) as response:
|
||||
response.raise_for_status()
|
||||
repo_data = await response.json()
|
||||
|
||||
@@ -97,7 +96,7 @@ class GitHubParser(BaseParser):
|
||||
|
||||
except aiohttp.ClientError as e:
|
||||
logger.error(f"[{self.name}] GitHub API请求失败: {e}")
|
||||
except json.JSONDecodeError as e:
|
||||
except ValueError as e:
|
||||
logger.error(f"[{self.name}] 解析GitHub API响应失败: {e}")
|
||||
except Exception as e:
|
||||
logger.error(f"[{self.name}] 获取仓库信息时发生未知错误: {e}")
|
||||
|
||||
Reference in New Issue
Block a user