From d90f02191c5693d0660bf9555dafbd3ae15bc074 Mon Sep 17 00:00:00 2001 From: liuwei Date: Fri, 30 May 2025 09:10:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=BA=BF=E7=A8=8B=E5=8F=91?= =?UTF-8?q?=E9=80=81=E3=80=82=E9=98=B2=E6=AD=A2=E9=98=BB=E5=A1=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/dashboard/blueprints/contacts.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/admin/dashboard/blueprints/contacts.py b/admin/dashboard/blueprints/contacts.py index ebc51a9..190086b 100644 --- a/admin/dashboard/blueprints/contacts.py +++ b/admin/dashboard/blueprints/contacts.py @@ -11,13 +11,10 @@ def send_message_in_thread(func, *args, **kwargs): """在独立线程中发送消息""" def run(): try: - loop = asyncio.new_event_loop() - asyncio.set_event_loop(loop) - loop.run_until_complete(func(*args, **kwargs)) + # 在新线程中运行异步函数 + asyncio.run(func(*args, **kwargs)) except Exception as e: logger.error(f"发送消息失败: {e}") - finally: - loop.close() # 创建并启动线程 thread = threading.Thread(target=run)