mirror of
https://github.com/codingo/Interlace.git
synced 2025-12-18 15:24:23 +01:00
Fixed blocker bug
This commit is contained in:
@@ -112,9 +112,11 @@ class InputHelper(object):
|
|||||||
if task_name == new_task_name:
|
if task_name == new_task_name:
|
||||||
return task_block
|
return task_block
|
||||||
# otherwise pre-process all the commands in this new `new_task_name` 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)
|
task_block.append(task)
|
||||||
sibling = task
|
if len(tasks) > 0:
|
||||||
|
sibling = tasks[-1]
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
# if a blocker is encountered, all commands following the blocker must wait until the last
|
# 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
|
# if we're in the global scope and there was a previous _blocker_ encountered, we wait for the last
|
||||||
# child of the block
|
# child of the block
|
||||||
if is_global_task and global_task:
|
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
|
# all but the first command in a block scope wait for its predecessor
|
||||||
elif sibling and not is_global_task:
|
elif sibling and not is_global_task:
|
||||||
task.wait_for(sibling.get_lock())
|
task.wait_for([sibling])
|
||||||
task_block.append(task)
|
task_block.append(task)
|
||||||
sibling = task
|
sibling = task
|
||||||
return task_block
|
return task_block
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class Task(object):
|
|||||||
def __init__(self, command):
|
def __init__(self, command):
|
||||||
self.task = command
|
self.task = command
|
||||||
self.self_lock = None
|
self.self_lock = None
|
||||||
self.sibling_lock = None
|
self.sibling_locks = []
|
||||||
|
|
||||||
def __cmp__(self, other):
|
def __cmp__(self, other):
|
||||||
return self.name() == other.name()
|
return self.name() == other.name()
|
||||||
@@ -20,21 +20,22 @@ class Task(object):
|
|||||||
def clone(self):
|
def clone(self):
|
||||||
new_task = Task(self.task)
|
new_task = Task(self.task)
|
||||||
new_task.self_lock = self.self_lock
|
new_task.self_lock = self.self_lock
|
||||||
new_task.sibling_lock = self.sibling_lock
|
new_task.sibling_locks = self.sibling_locks
|
||||||
return new_task
|
return new_task
|
||||||
|
|
||||||
def replace(self, old, new):
|
def replace(self, old, new):
|
||||||
self.task = self.task.replace(old, new)
|
self.task = self.task.replace(old, new)
|
||||||
|
|
||||||
def run(self, t=False):
|
def run(self, t=False):
|
||||||
if self.sibling_lock:
|
for lock in self.sibling_locks:
|
||||||
self.sibling_lock.wait()
|
lock.wait()
|
||||||
self._run_task(t)
|
self._run_task(t)
|
||||||
if self.self_lock:
|
if self.self_lock:
|
||||||
self.self_lock.set()
|
self.self_lock.set()
|
||||||
|
|
||||||
def wait_for(self, _lock):
|
def wait_for(self, siblings):
|
||||||
self.sibling_lock = _lock
|
for sibling in siblings:
|
||||||
|
self.sibling_locks.append(sibling.get_lock())
|
||||||
|
|
||||||
def name(self):
|
def name(self):
|
||||||
return self.task
|
return self.task
|
||||||
|
|||||||
Reference in New Issue
Block a user