mirror of
https://github.com/MeoProject/lx-music-api-server.git
synced 2025-05-23 19:17:41 +08:00
feat: 优化scheduler执行,现在所有可执行的任务会一起执行
This commit is contained in:
parent
1d523dc07a
commit
6c68d03b96
@ -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():
|
||||
|
Loading…
x
Reference in New Issue
Block a user