feat: 优化scheduler执行,现在所有可执行的任务会一起执行

This commit is contained in:
helloplhm-qwq 2023-12-24 18:40:07 +08:00
parent 1d523dc07a
commit 6c68d03b96
No known key found for this signature in database
GPG Key ID: B7542212855B2C26

View File

@ -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():