Merge pull request #66 from iamOgunyinka/flat

Fixed blocker bug
This commit is contained in:
Michael Skelton
2019-08-20 22:29:27 +10:00
committed by GitHub
2 changed files with 13 additions and 10 deletions

View File

@@ -112,9 +112,11 @@ class InputHelper(object):
if task_name == new_task_name:
return task_block
# otherwise pre-process all the commands in this new `new_task_name` block
for task in InputHelper._pre_process_commands(command_list, new_task_name, False):
tasks = InputHelper._pre_process_commands(command_list, new_task_name, False)
for task in tasks:
task_block.append(task)
sibling = task
if len(tasks) > 0:
sibling = tasks[-1]
continue
else:
# if a blocker is encountered, all commands following the blocker must wait until the last
@@ -126,10 +128,10 @@ class InputHelper(object):
# if we're in the global scope and there was a previous _blocker_ encountered, we wait for the last
# child of the block
if is_global_task and global_task:
task.wait_for(global_task.get_lock())
task.wait_for(task_block)
# all but the first command in a block scope wait for its predecessor
elif sibling and not is_global_task:
task.wait_for(sibling.get_lock())
task.wait_for([sibling])
task_block.append(task)
sibling = task
return task_block

View File

@@ -9,7 +9,7 @@ class Task(object):
def __init__(self, command):
self.task = command
self.self_lock = None
self.sibling_lock = None
self.sibling_locks = []
def __cmp__(self, other):
return self.name() == other.name()
@@ -20,21 +20,22 @@ class Task(object):
def clone(self):
new_task = Task(self.task)
new_task.self_lock = self.self_lock
new_task.sibling_lock = self.sibling_lock
new_task.sibling_locks = self.sibling_locks
return new_task
def replace(self, old, new):
self.task = self.task.replace(old, new)
def run(self, t=False):
if self.sibling_lock:
self.sibling_lock.wait()
for lock in self.sibling_locks:
lock.wait()
self._run_task(t)
if self.self_lock:
self.self_lock.set()
def wait_for(self, _lock):
self.sibling_lock = _lock
def wait_for(self, siblings):
for sibling in siblings:
self.sibling_locks.append(sibling.get_lock())
def name(self):
return self.task