本文整理汇总了Python中doit.control.TaskControl.task_dispatcher方法的典型用法代码示例。如果您正苦于以下问题:Python TaskControl.task_dispatcher方法的具体用法?Python TaskControl.task_dispatcher怎么用?Python TaskControl.task_dispatcher使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类doit.control.TaskControl
的用法示例。
在下文中一共展示了TaskControl.task_dispatcher方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: doit_auto
# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import task_dispatcher [as 别名]
def doit_auto(dependency_file, task_list, filter_tasks, loop_callback=None):
"""Re-execute tasks automatically a depedency changes
@param filter_tasks (list -str): print only tasks from this list
@loop_callback: used to stop loop on unittests
"""
task_control = TaskControl(task_list)
task_control.process(filter_tasks)
tasks_to_run = list(set([t for t in task_control.task_dispatcher(True)]))
watch_tasks = [t.name for t in tasks_to_run]
watch_files = list(itertools.chain(*[s.file_dep for s in tasks_to_run]))
watch_files = list(set(watch_files))
class DoitAutoRun(FileModifyWatcher):
"""Execute doit on event handler of file changes """
def handle_event(self, event):
doit_run(dependency_file, task_list, sys.stdout,
watch_tasks, reporter='executed-only')
# reset run_status
for task in task_list:
task.run_status = None
file_watcher = DoitAutoRun(watch_files)
# always run once when started
file_watcher.handle_event(None)
file_watcher.loop(loop_callback)
示例2: test_delayed_creation
# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import task_dispatcher [as 别名]
def test_delayed_creation(self):
def creator():
yield {'name': 'foo1', 'actions': None, 'file_dep': ['bar']}
yield {'name': 'foo2', 'actions': None, 'targets': ['bar']}
delayed_loader = DelayedLoader(creator, executed='t2')
tasks = [Task('t0', None, task_dep=['t1']),
Task('t1', None, loader=delayed_loader),
Task('t2', None)]
control = TaskControl(tasks)
control.process(['t0'])
disp = control.task_dispatcher()
gen = disp.generator
nt2 = next(gen)
assert nt2.task.name == "t2"
# wait for t2 to be executed
assert "hold on" == next(gen)
assert "hold on" == next(gen) # hold until t2 is done
# delayed creation of tasks for t1 does not mess existing info
assert disp.nodes['t1'].waiting_me == set([disp.nodes['t0']])
nf2 = gen.send(nt2)
assert disp.nodes['t1'].waiting_me == set([disp.nodes['t0']])
assert nf2.task.name == "t1:foo2"
nf1 = gen.send(nf2)
assert nf1.task.name == "t1:foo1"
assert nf1.task.task_dep == ['t1:foo2'] # implicit dep added
nt1 = gen.send(nf1)
assert nt1.task.name == "t1"
nt0 = gen.send(nt1)
assert nt0.task.name == "t0"
pytest.raises(StopIteration, lambda gen: next(gen), gen)
示例3: test_include_setup
# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import task_dispatcher [as 别名]
def test_include_setup(self):
tasks = [Task("t1", None, task_dep=["t2"]),
Task("t2", None,)]
control = TaskControl(tasks)
control.process(['t1'])
gen = control.task_dispatcher(include_setup=True).generator
# dont wait for tasks
assert tasks[0] == gen.send(None).task
assert tasks[1] == gen.send(None).task
pytest.raises(StopIteration, gen.send, None)
示例4: test_normal
# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import task_dispatcher [as 别名]
def test_normal(self):
tasks = [Task("t1", None, task_dep=["t2"]),
Task("t2", None,)]
control = TaskControl(tasks)
control.process(['t1'])
gen = control.task_dispatcher().generator
n2 = next(gen)
assert tasks[1] == n2.task
assert "hold on" == next(gen)
assert "hold on" == next(gen) # hold until t2 is done
assert tasks[0] == gen.send(n2).task
pytest.raises(StopIteration, lambda gen: next(gen), gen)
示例5: testAllTasksWaiting
# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import task_dispatcher [as 别名]
def testAllTasksWaiting(self):
tasks = [Task("taskX",None,setup=["taskY"]),
Task("taskY",None,)]
tc = TaskControl(tasks)
tc.process(['taskX'])
gen = tc.task_dispatcher()
assert tasks[0] == gen.next() # tasks with setup are yield twice
assert "hold on" == gen.next() # nothing else really available
tasks[0].run_status = 'run' # should be executed
assert tasks[1] == gen.next() # execute setup before
assert tasks[0] == gen.next() # second time, ok
py.test.raises(StopIteration, gen.next) # nothing left
示例6: testChangeOrder_AddJustOnce
# 需要导入模块: from doit.control import TaskControl [as 别名]
# 或者: from doit.control.TaskControl import task_dispatcher [as 别名]
def testChangeOrder_AddJustOnce(self):
tasks = [Task("taskX",None,task_dep=["taskY"]),
Task("taskY",None,)]
tc = TaskControl(tasks)
tc.process(None)
assert [tasks[1], tasks[0]] == [x for x in tc.task_dispatcher()]