I have two scripts inside a bigger system I'm developing. Lets call one foo.py
and the other one bar.py
.
foo
creates files that bar
will afterwards read and delete. Now, if foo
is running and working on a file, bar
will mess things up by working on the same file before foo
is finished.
foo
and bar
get started automatically by other stuff, not manually by someone that runs them. How can I make sure that, if foo
is working on a file, bar
will not start?
I have thought about editing both of them so that foo
writes a 1 to a text file at the beginning of the execution and a 0 when it finishes, and to make bar
read the text file to check wheter it can start. But I'm not really sure this is the most elegant solution, and also I don't want to block bar
if foo
ever fails in the middle of execution, leaving the file at 1.