本文整理汇总了Python中doit.control.TaskDispatcher类的典型用法代码示例。如果您正苦于以下问题:Python TaskDispatcher类的具体用法?Python TaskDispatcher怎么用?Python TaskDispatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TaskDispatcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delayed_creation
def test_delayed_creation(self):
def creator():
yield Task('foo', None, loader=DelayedLoader(lambda : None))
delayed_loader = DelayedLoader(creator, executed='t2')
tasks = {'t1': Task('t1', None, loader=delayed_loader),
't2': Task('t2', None),
}
td = TaskDispatcher(tasks, [], None)
n1 = td._gen_node(None, 't1')
gen = td._add_task(n1)
# first returned node is `t2` because it is an implicit task_dep
n2 = next(gen)
assert n2.task.name == 't2'
# wait until t2 is finished
n3 = next(gen)
assert n3 == 'wait'
# after t2 is done, generator is reseted
td._update_waiting(n2)
n4 = next(gen)
assert n4 == "reset generator"
# recursive loader is preserved
assert isinstance(td.tasks['foo'].loader, DelayedLoader)
pytest.raises(AssertionError, next, gen)
示例2: test_already_created
def test_already_created(self):
tasks = {'t1': Task('t1', None),
't2': Task('t2', None)
}
td = TaskDispatcher(tasks, [], None)
n1 = td._gen_node(None, 't1')
td._gen_node(n1, 't2')
assert None == td._gen_node(None, 't1')
示例3: test_cyclic
def test_cyclic(self):
tasks = {'t1': Task('t1', None),
't2': Task('t2', None)
}
td = TaskDispatcher(tasks, [], None)
n1 = td._gen_node(None, 't1')
n2 = td._gen_node(n1, 't2')
pytest.raises(InvalidDodoFile, td._gen_node, n2, 't1')
示例4: test_to_run_none
def test_to_run_none(self):
tasks = {'t1': Task('t1', None),
}
td = TaskDispatcher(tasks, [], None)
td._gen_node(None, 't1') # t1 was already created
to_run = ['t1']
assert None == td._get_next_node([], to_run)
assert [] == to_run
示例5: test_ready
def test_ready(self):
tasks = {'t1': Task('t1', None),
't2': Task('t2', None),
}
td = TaskDispatcher(tasks, [], None)
n1 = td._gen_node(None, 't1')
ready = deque([n1])
assert n1 == td._get_next_node(ready, ['t2'])
assert 0 == len(ready)
示例6: test_none
def test_none(self):
tasks = {'t1': Task('t1', None),
't2': Task('t2', None),
}
td = TaskDispatcher(tasks, [], None)
n1 = td._gen_node(None, 't1')
n2 = td._gen_node(None, 't2')
n2.run_status = 'done'
td._node_add_wait_run(n1, ['t2'])
assert not n1.wait_run
示例7: test_task_deps_no_wait
def test_task_deps_no_wait(self):
tasks = {'t1': Task('t1', None, task_dep=['t2']),
't2': Task('t2', None),
}
td = TaskDispatcher(tasks, [], None)
n1 = td._gen_node(None, 't1')
n2 = td._gen_node(None, 't2')
n2.run_status = 'done'
gen = td._add_task(n1)
assert tasks['t1'] == next(gen)
示例8: test_deps_not_ok
def test_deps_not_ok(self):
tasks = {'t1': Task('t1', None),
't2': Task('t2', None),
}
td = TaskDispatcher(tasks, [], None)
n1 = td._gen_node(None, 't1')
n2 = td._gen_node(None, 't2')
n2.run_status = 'failure'
td._node_add_wait_run(n1, ['t2'])
assert n1.bad_deps
示例9: test_to_run
def test_to_run(self):
tasks = {'t1': Task('t1', None, task_dep=['t2']),
't2': Task('t2', None),
}
td = TaskDispatcher(tasks, [], None)
to_run = ['t2', 't1']
td._gen_node(None, 't1') # t1 was already created
got = td._get_next_node([], to_run)
assert isinstance(got, ExecNode)
assert 't2' == got.task.name
assert [] == to_run
示例10: test_task_deps_already_created
def test_task_deps_already_created(self):
tasks = {'t1': Task('t1', None, task_dep=['t2']),
't2': Task('t2', None),
}
td = TaskDispatcher(tasks, [], None)
n1 = td._gen_node(None, 't1')
n2 = td._gen_node(None, 't2')
assert 'wait' == n1.step()
assert 'wait' == n1.step()
#tasks['t2'].run_status = 'done'
td._update_waiting(n2)
assert tasks['t1'] == n1.step()
示例11: test_wait_select
def test_wait_select(self):
tasks = {'t1': Task('t1', None, task_dep=['t2']),
't2': Task('t2', None),
}
td = TaskDispatcher(tasks, [], None)
n2 = td._gen_node(None, 't2')
n2.wait_select = True
n2.run_status = 'run'
td.waiting.add(n2)
td._update_waiting(n2)
assert False == n2.wait_select
assert deque([n2]) == td.ready
示例12: test_setup_task__run
def test_setup_task__run(self):
tasks = {'t1': Task('t1', None, setup=['t2']),
't2': Task('t2', None),
}
td = TaskDispatcher(tasks, [], None)
n1 = td._gen_node(None, 't1')
gen = td._add_task(n1)
assert tasks['t1'] == next(gen) # first time (just select)
assert 'wait' == next(gen) # wait for select result
n1.run_status = 'run'
assert tasks['t2'] == next(gen).task # send setup task
assert 'wait' == next(gen)
assert tasks['t1'] == next(gen) # second time
示例13: test_calc_dep_already_executed
def test_calc_dep_already_executed(self):
tasks = {'t1': Task('t1', None, calc_dep=['t2']),
't2': Task('t2', None),
't3': Task('t3', None),
}
td = TaskDispatcher(tasks, {'intermediate': 't3'}, None)
n1 = td._gen_node(None, 't1')
n2 = td._gen_node(None, 't2')
n2.run_status = 'done'
n2.task.values = {'calc_dep': ['t3']}
assert 't3' == n1.step().task.name
assert set() == n1.wait_run
assert set() == n1.wait_run_calc
示例14: test_wait
def test_wait(self):
tasks = {'t1': Task('t1', None),
't2': Task('t2', None),
}
td = TaskDispatcher(tasks, [], None)
n1 = td._gen_node(None, 't1')
n2 = td._gen_node(None, 't2')
n1.wait_run.add('xxx')
td._node_add_wait_run(n1, ['t2'])
assert 2 == len(n1.wait_run)
assert 't2' in n1.wait_run
assert not n1.bad_deps
assert n1 in n2.waiting_me
示例15: test_regex_not_found
def test_regex_not_found(self):
def creator1():
yield Task('foo1', None, targets=['tgt1'])
delayed_loader1 = DelayedLoader(creator1, target_regex='tgt.*')
t1 = Task('t1', None, loader=delayed_loader1)
tc = TaskControl([t1])
selection = tc._filter_tasks(['tgt666'])
assert ['_regex_target_tgt666:t1'] == selection
td = TaskDispatcher(tc.tasks, tc.targets, selection)
n1 = td._gen_node(None, '_regex_target_tgt666:t1')
gen = td._add_task(n1)
# target not found after generating all tasks from regex group
pytest.raises(InvalidCommand, next, gen)