Skip to content

Commit

Permalink
feat: 优化scheduler执行,现在所有可执行的任务会一起执行
Browse files Browse the repository at this point in the history
  • Loading branch information
helloplhm-qwq committed Dec 24, 2023
1 parent 1d523dc commit 6c68d03
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion common/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 6c68d03

Please sign in to comment.