Sort pending tasks in correct order

This commit is contained in:
Yingtong Li 2018-01-04 10:51:37 +08:00
parent 3fae9cf22d
commit 1962c1759f
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
1 changed files with 3 additions and 0 deletions

View File

@ -69,6 +69,9 @@ class TaskScheduler:
if task.status == Task.Status.READY:
pending_tasks.append(task)
# Sort them to ensure we iterate over them in the correct order
pending_tasks.sort(key=lambda task: task.run_at.timestamp() if task.run_at else 0)
return pending_tasks
@staticmethod