🤖 自动格式化代码 [skip ci]

This commit is contained in:
github-actions[bot]
2025-06-14 17:45:19 +00:00
parent 3130b76320
commit b9c3cd8ab3
5 changed files with 67 additions and 60 deletions

View File

@@ -335,8 +335,6 @@ async def clean_unused_emojis(emoji_dir: str, emoji_objects: List["MaiEmoji"], r
for file_name in os.listdir(emoji_dir): for file_name in os.listdir(emoji_dir):
file_full_path = os.path.join(emoji_dir, file_name) file_full_path = os.path.join(emoji_dir, file_name)
# 确保处理的是文件而不是子目录 # 确保处理的是文件而不是子目录
if not os.path.isfile(file_full_path): if not os.path.isfile(file_full_path):
continue continue

View File

@@ -298,7 +298,9 @@ class HeartFChatting:
# 使用异步上下文管理器处理消息 # 使用异步上下文管理器处理消息
try: try:
async with global_prompt_manager.async_message_scope(self.chat_stream.context.get_template_name()): async with global_prompt_manager.async_message_scope(
self.chat_stream.context.get_template_name()
):
# 在上下文内部检查关闭状态 # 在上下文内部检查关闭状态
if self._shutting_down: if self._shutting_down:
logger.info(f"{self.log_prefix} 在处理上下文中检测到关闭信号,退出") logger.info(f"{self.log_prefix} 在处理上下文中检测到关闭信号,退出")
@@ -357,7 +359,9 @@ class HeartFChatting:
timer_strings.append(f"{name}: {formatted_time}") timer_strings.append(f"{name}: {formatted_time}")
# 新增:输出每个处理器的耗时 # 新增:输出每个处理器的耗时
processor_time_costs = self._current_cycle_detail.loop_processor_info.get("processor_time_costs", {}) processor_time_costs = self._current_cycle_detail.loop_processor_info.get(
"processor_time_costs", {}
)
processor_time_strings = [] processor_time_strings = []
for pname, ptime in processor_time_costs.items(): for pname, ptime in processor_time_costs.items():
formatted_ptime = f"{ptime * 1000:.2f}毫秒" if ptime < 1 else f"{ptime:.2f}" formatted_ptime = f"{ptime * 1000:.2f}毫秒" if ptime < 1 else f"{ptime:.2f}"

View File

@@ -196,7 +196,9 @@ class NormalChat:
# 使用异步上下文管理器处理消息 # 使用异步上下文管理器处理消息
try: try:
async with global_prompt_manager.async_message_scope(self.chat_stream.context.get_template_name()): async with global_prompt_manager.async_message_scope(
self.chat_stream.context.get_template_name()
):
# 在上下文内部再次检查取消状态 # 在上下文内部再次检查取消状态
if self._disabled: if self._disabled:
logger.info(f"[{self.stream_name}] 在处理上下文中检测到停止信号,退出") logger.info(f"[{self.stream_name}] 在处理上下文中检测到停止信号,退出")

View File

@@ -4,12 +4,12 @@ NormalChat 启动停止测试脚本
""" """
import asyncio import asyncio
import time
import logging import logging
from src.common.logger import get_logger from src.common.logger import get_logger
logger = get_logger("test_normal_chat_stop") logger = get_logger("test_normal_chat_stop")
async def test_task_cancel_behavior(): async def test_task_cancel_behavior():
"""测试任务取消行为""" """测试任务取消行为"""
@@ -85,6 +85,7 @@ async def test_task_cancel_behavior():
logger.info("=== 测试完成 ===") logger.info("=== 测试完成 ===")
async def main(): async def main():
"""主函数""" """主函数"""
logger.info("开始 NormalChat 停止测试") logger.info("开始 NormalChat 停止测试")
@@ -94,10 +95,12 @@ async def main():
except Exception as e: except Exception as e:
logger.error(f"测试失败: {e}") logger.error(f"测试失败: {e}")
import traceback import traceback
logger.error(traceback.format_exc()) logger.error(traceback.format_exc())
logger.info("测试结束") logger.info("测试结束")
if __name__ == "__main__": if __name__ == "__main__":
# 设置日志级别 # 设置日志级别
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)