From 62e39dd0e248be0d89689709d3c0caaaf930a626 Mon Sep 17 00:00:00 2001 From: Sakura-RanChen <1908198662@qq.com> Date: Wed, 9 Jul 2025 11:18:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=AD=89=E5=BE=85=E6=97=B6=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E5=B7=B2=E7=BB=8F=E5=AE=8C=E6=88=90=EF=BC=88=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E4=B8=BANone=EF=BC=89=EF=BC=8C=E5=90=8E=E7=BB=AD?= =?UTF-8?q?=E5=AF=B9None=E9=94=99=E8=AF=AF=E8=AE=BF=E9=97=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../providers/tts/huoshan_double_stream.py | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/main/xiaozhi-server/core/providers/tts/huoshan_double_stream.py b/main/xiaozhi-server/core/providers/tts/huoshan_double_stream.py index 49643b85..e6e4d2fa 100644 --- a/main/xiaozhi-server/core/providers/tts/huoshan_double_stream.py +++ b/main/xiaozhi-server/core/providers/tts/huoshan_double_stream.py @@ -364,20 +364,9 @@ class TTSProvider(TTSProviderBase): logger.bind(tag=TAG).info("会话结束请求已发送") # 等待监听任务完成 - if hasattr(self, "_monitor_task") and self._monitor_task is not None: + if self._monitor_task: try: - # 设置4秒超时等待监听任务结束 - await asyncio.wait_for(self._monitor_task, timeout=4) - except asyncio.TimeoutError: - logger.bind(tag=TAG).warning("等待监听任务超时,强制取消") - if not self._monitor_task.done(): - self._monitor_task.cancel() - try: - await self._monitor_task - except asyncio.CancelledError: - pass - except Exception as e: - logger.bind(tag=TAG).warning(f"监听任务取消时发生错误: {e}") + await self._monitor_task except Exception as e: logger.bind(tag=TAG).error( f"等待监听任务完成时发生错误: {str(e)}" @@ -394,7 +383,7 @@ class TTSProvider(TTSProviderBase): async def close(self): """资源清理方法""" # 取消监听任务 - if self._monitor_task and not self._monitor_task.done(): + if self._monitor_task: try: self._monitor_task.cancel() await self._monitor_task @@ -402,7 +391,7 @@ class TTSProvider(TTSProviderBase): pass except Exception as e: logger.bind(tag=TAG).warning(f"关闭时取消监听任务错误: {e}") - self._monitor_task = None + self._monitor_task = None if self.ws: try: