From 60310a6fb8d0d60b14aa875cc8063a93dc21e3e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B6=B5=E6=9B=A6?= Date: Mon, 5 Jan 2026 14:15:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20python3.14=20?= =?UTF-8?q?=E4=B8=AD=E6=97=A0=E6=B3=95=E8=BF=90=E8=A1=8C=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiaomusic/xiaomusic.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/xiaomusic/xiaomusic.py b/xiaomusic/xiaomusic.py index c7998d2..6aaf37c 100644 --- a/xiaomusic/xiaomusic.py +++ b/xiaomusic/xiaomusic.py @@ -796,12 +796,14 @@ class XiaoMusic: def try_gen_all_music_tag(self, only_items: dict = None): if self.ensure_single_thread_for_tag(): - loop = asyncio.get_event_loop() - if loop.is_running(): - asyncio.ensure_future(self._gen_all_music_tag(only_items)) - self.log.info("启动后台构建 tag cache") - else: + try: + asyncio.get_running_loop() + except RuntimeError: + # 没有运行中的事件循环,跳过 self.log.info("协程时间循环未启动") + return + asyncio.ensure_future(self._gen_all_music_tag(only_items)) + self.log.info("启动后台构建 tag cache") async def _gen_all_music_tag(self, only_items: dict = None): self._tag_generation_task = True @@ -930,7 +932,7 @@ class XiaoMusic: if not (v.startswith("http") or v.startswith("https")): self._extra_index_search[v] = k - # all_music 更新,重建 tag + # all_music 更新,重建 tag(仅在事件循环启动后才会执行) self.try_gen_all_music_tag() def refresh_custom_play_list(self): @@ -997,7 +999,8 @@ class XiaoMusic: try: loop = asyncio.get_running_loop() except RuntimeError: - loop = asyncio.get_event_loop() + self.log.warning("无法获取运行中的事件循环,目录监控功能可能无法正常工作") + return # 延时配置项 file_watch_debounce self._file_watch_handler = XiaoMusicPathWatch( callback=self._on_file_change,