From 9602b31014fb5128d5857faf5ed0768256d5a14a Mon Sep 17 00:00:00 2001 From: SXP-Simon Date: Tue, 23 Sep 2025 23:26:12 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20(debug)=20=E7=BA=A0=E6=AD=A3=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E7=AD=89=E7=BA=A7=E6=83=85=E5=86=B5=EF=BC=8C=E7=BA=A0?= =?UTF-8?q?=E6=AD=A3=E4=B8=8D=E8=83=BD=E9=80=82=E9=85=8D=E4=BD=8E=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E7=9A=84=E7=9A=84=20async=20timeout=20=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 2 +- src/analysis/llm_analyzer.py | 6 +++--- src/scheduler/auto_scheduler.py | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index c1d0560..8652bc0 100644 --- a/main.py +++ b/main.py @@ -79,7 +79,7 @@ class QQGroupDailyAnalysis(Star): logger.info(f"Bot管理器状态: {status}") except Exception as e: - logger.error(f"延迟启动调度器失败: {e}") + logger.debug(f"延迟启动调度器失败,可能由于短时间内多次更新插件配置: {e}") async def terminate(self): """插件被卸载/停用时调用,清理资源""" diff --git a/src/analysis/llm_analyzer.py b/src/analysis/llm_analyzer.py index bd5bb34..3ad0d27 100644 --- a/src/analysis/llm_analyzer.py +++ b/src/analysis/llm_analyzer.py @@ -253,7 +253,7 @@ class LLMAnalyzer: else: logger.warning(f"话题分析响应中未找到JSON格式,响应内容: {result_text[:200]}...") except json.JSONDecodeError as e: - logger.error(f"话题分析JSON解析失败: {e}") + logger.debug(f"话题分析JSON解析失败: {e}") logger.debug(f"修复后的JSON: {json_text if 'json_text' in locals() else 'N/A'}") logger.debug(f"原始响应: {result_text}") @@ -467,7 +467,7 @@ class LLMAnalyzer: titles_data = json.loads(json_match.group()) return [UserTitle(**title) for title in titles_data], token_usage except Exception as e: - logger.error(f"用户称号分析JSON解析失败: {e}") + logger.debug(f"用户称号分析JSON解析失败: {e}") logger.debug(f"原始响应: {result_text}") return [], token_usage @@ -570,7 +570,7 @@ class LLMAnalyzer: quotes_data = json.loads(json_match.group()) return [GoldenQuote(**quote) for quote in quotes_data[:max_golden_quotes]], token_usage except Exception as e: - logger.error(f"金句分析JSON解析失败: {e}") + logger.debug(f"金句分析JSON解析失败: {e}") logger.debug(f"原始响应: {result_text}") return [], token_usage diff --git a/src/scheduler/auto_scheduler.py b/src/scheduler/auto_scheduler.py index 51a8834..1647f1f 100644 --- a/src/scheduler/auto_scheduler.py +++ b/src/scheduler/auto_scheduler.py @@ -157,9 +157,8 @@ class AutoScheduler: async def _perform_auto_analysis_for_group_with_timeout(self, group_id: str): """为指定群执行自动分析(带超时控制)""" try: - # 为每个群聊设置独立的超时时间(20分钟) - async with asyncio.timeout(1200): - await self._perform_auto_analysis_for_group(group_id) + # 为每个群聊设置独立的超时时间(20分钟)- 使用 asyncio.wait_for 兼容所有 Python 版本 + await asyncio.wait_for(self._perform_auto_analysis_for_group(group_id), timeout=1200) except asyncio.TimeoutError: logger.error(f"群 {group_id} 分析超时(20分钟),跳过该群分析") except Exception as e: