From 6c68d03b96f845a73ebfee5c63b095979bb87267 Mon Sep 17 00:00:00 2001 From: helloplhm-qwq Date: Sun, 24 Dec 2023 18:40:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96scheduler=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=EF=BC=8C=E7=8E=B0=E5=9C=A8=E6=89=80=E6=9C=89=E5=8F=AF?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E7=9A=84=E4=BB=BB=E5=8A=A1=E4=BC=9A=E4=B8=80?= =?UTF-8?q?=E8=B5=B7=E6=89=A7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/scheduler.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/scheduler.py b/common/scheduler.py index 9791e50..136d076 100644 --- a/common/scheduler.py +++ b/common/scheduler.py @@ -49,10 +49,13 @@ def append(name, task, interval = 86400): async def thread_runner(): global tasks, running_event while not running_event.is_set(): + tasks_runner = [] for t in tasks: if t.check_available() and not running_event.is_set(): t.latest_execute = int(time.time()) - await t.run() # 等待异步任务完成 + tasks_runner.append(t.run()) + if (tasks_runner): + await asyncio.gather(*tasks_runner) await asyncio.sleep(1) async def run():