diff --git a/src/integrations/feishu_longconn_service.py b/src/integrations/feishu_longconn_service.py index 29fe981..e5cc7ec 100644 --- a/src/integrations/feishu_longconn_service.py +++ b/src/integrations/feishu_longconn_service.py @@ -55,6 +55,14 @@ class FeishuLongConnService: self._executor = ThreadPoolExecutor(max_workers=5, thread_name_prefix="feishu_msg") self._msg_count = 0 + # 预初始化 Pipeline(避免首条消息时懒加载导致超时) + try: + self._pipeline = service_manager.get_pipeline() + logger.info("✅ MessagePipeline 预初始化成功") + except Exception as e: + logger.error(f"❌ MessagePipeline 预初始化失败: {e}", exc_info=True) + self._pipeline = None + def _handle_message(self, data: P2ImMessageReceiveV1) -> None: """收到消息事件,立即提交到线程池,确保 SDK 回调快速返回""" self._msg_count += 1 @@ -68,6 +76,8 @@ class FeishuLongConnService: self._process_message(data) except Exception as e: logger.error(f"❌ 消息 #{msg_no} 处理异常: {e}", exc_info=True) + import sys + sys.stderr.flush() try: mid = data.event.message.message_id self._reply_message(mid, "抱歉,系统遇到了一些问题,请稍后重试。") @@ -166,8 +176,9 @@ class FeishuLongConnService: # 使用 Pipeline 统一处理消息 session_user_id = f"feishu_{chat_id}_{sender_id}" try: - pipeline = service_manager.get_pipeline() - logger.info(f"Pipeline 开始处理: user={session_user_id}, chat_id={chat_id}") + logger.info(f"正在获取 Pipeline...") + pipeline = self._pipeline or service_manager.get_pipeline() + logger.info(f"Pipeline 开始处理: user={session_user_id}") response_data = pipeline.handle_message( user_id=session_user_id, message=text_content,