Feat: scheduler handle dependencies (basic)

This commit is contained in:
2022-04-08 21:49:18 +02:00
parent bfe9e6f91e
commit e0377a3e92
2 changed files with 33 additions and 1 deletions

View File

@@ -19,12 +19,19 @@ class Scheduler:
self._tasks += tasks
def dispatch(self, task):
""" Do a task """
"""Do a task"""
ans = self.actions[task.action](task.deps, task.args)
return ans
def __next__(self):
undoable = []
task = self._tasks.pop(0)
while not all([d in self.done for d in task.deps]):
undoable.append(task)
task = self._tasks.pop(0)
self.append(undoable)
ans = self.dispatch(task)
self._done.append(ans)
return ans