Search code examples
doit

Waiting for dependencies when running in parallel


When running doit with -n option, the task doesn't seem to wait for the file_dep to be created by other sub-tasks. Here is a simple code that tries to show the issue:

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 runs without a problem. However when running doit -n 2 -s pexample, it starts the second subtask right away, without waiting for the first one to complete. This then generates an error since the file doesn't exist.

My question is whether doit does or doesn't look for such dependencies in subtask when running in parallel?


Solution

  • Yes. doit looks for dependencies when executing in parallel.

    The problem with your example is that you are using the -s/--single command line option. -s instructs doit to execute the specified task ignoring the dependencies.

    -s is supposed to be used on special occasions while developing your task's code, not be used during standard execution.