运行 并行等待依赖
Waiting for dependencies when running in parallel
当 运行 使用 -n
选项时,任务似乎不会等待其他子任务创建 file_dep
。这是一个试图显示问题的简单代码:
def task_pexample():
yield {
"name":"test1",
"actions": ["sleep 5", "touch tmp.txt"],
"targets":["tmp.txt"]
}
yield {
"name":"test2",
"file_dep":["tmp.txt"],
"targets":["tmp2.txt"],
"actions": ["cp tmp.txt tmp2.txt"],
}
doit -s pexample
运行没有问题。但是当 运行 doit -n 2 -s pexample
时,它会立即开始第二个子任务,而不会等待第一个子任务完成。由于文件不存在,这会产生错误。
我的问题是 doit
是否在 运行 并行时在子任务中查找或不查找此类依赖项?
是的。 doit
并行执行时查找依赖项。
您的示例的问题在于您使用的是 -s/--single
命令行选项。 -s
指示 doit
忽略依赖关系执行指定的任务。
-s
应该在开发任务代码时的特殊情况下使用,而不是在标准执行期间使用。
当 运行 使用 -n
选项时,任务似乎不会等待其他子任务创建 file_dep
。这是一个试图显示问题的简单代码:
def task_pexample():
yield {
"name":"test1",
"actions": ["sleep 5", "touch tmp.txt"],
"targets":["tmp.txt"]
}
yield {
"name":"test2",
"file_dep":["tmp.txt"],
"targets":["tmp2.txt"],
"actions": ["cp tmp.txt tmp2.txt"],
}
doit -s pexample
运行没有问题。但是当 运行 doit -n 2 -s pexample
时,它会立即开始第二个子任务,而不会等待第一个子任务完成。由于文件不存在,这会产生错误。
我的问题是 doit
是否在 运行 并行时在子任务中查找或不查找此类依赖项?
是的。 doit
并行执行时查找依赖项。
您的示例的问题在于您使用的是 -s/--single
命令行选项。 -s
指示 doit
忽略依赖关系执行指定的任务。
-s
应该在开发任务代码时的特殊情况下使用,而不是在标准执行期间使用。