From 787db8f5ac40a738da2d00767b8f2ccf84c3bc36 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Fri, 17 Apr 2026 13:02:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=AD=90=E8=BF=9B?= =?UTF-8?q?=E7=A8=8B=E7=8E=AF=E5=A2=83=E4=B8=8B=E8=8E=B7=E5=8F=96=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E5=BE=AA=E7=8E=AF=E5=A4=B1=E8=B4=A5=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 --- app/core/config.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/core/config.py b/app/core/config.py index 0d07bec6..88d3756a 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -1046,7 +1046,16 @@ class GlobalVar(object): # 需应急停止文件整理 EMERGENCY_STOP_TRANSFER: List[str] = [] # 当前事件循环 - CURRENT_EVENT_LOOP: AbstractEventLoop = asyncio.get_event_loop() + CURRENT_EVENT_LOOP: AbstractEventLoop = None + + @classmethod + def _get_event_loop(cls) -> AbstractEventLoop: + try: + return asyncio.get_event_loop() + except RuntimeError: + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + return loop def stop_system(self): """ @@ -1116,6 +1125,8 @@ class GlobalVar(object): """ 当前循环 """ + if self.CURRENT_EVENT_LOOP is None: + self.CURRENT_EVENT_LOOP = self._get_event_loop() return self.CURRENT_EVENT_LOOP def set_loop(self, loop: AbstractEventLoop):