Consider the following dodo.py
file:
#!/usr/bin/env doit -f
def cat(infile, outfile):
with open(infile, "r") as in_, open(outfile, "w") as out:
out.writelines(in_.readlines())
def task_generate_file2_from_file1():
return {
# Task reads the input file early, but takes a long time to
# complete
'actions': [
(cat, ('file1.txt', 'file2.txt')),
["sleep", "2"],
],
'file_dep': ['file1.txt'],
'targets': ['file2.txt'],
'clean': True,
}
Note that the task doesn't "finish" until 2 seconds after the output file is written.
Now, source the following (must be sourced, not executed, so that job control is available):
#!/bin/sh
# Clean any previous runs
doit clean -a
# Generate initial contents of input file
echo "Original text" > file1.txt
# Modify the input file while doit is running
doit & sleep 1; echo "New text" > file1.txt; fg
# Show that the output file is out of date
echo -n "Contents of file1.txt: "; cat file1.txt
echo -n "Contents of file2.txt: "; cat file2.txt
# Try to run doit again; it believes that task is up-to-date
doit
and you will see the following:
$ source produce_bug.sh
generate_file2_from_file1 - removing file 'file2.txt'
[2] 3199
. generate_file2_from_file1
[2] - running doit
Contents of file1.txt: New text
Contents of file2.txt: Original text
-- generate_file2_from_file1
As indicated in the comments of the shell script, my expectation is that the final call to doit should rebuild file2.txt, however, it fails to do so. I assume this is because doit does not record the contents of the input files until after the task is completed, which in this causes it to record the new contents of the input file, even though the task actually ran on the old contents.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too