I have a very simple build script that's behaving in an unexpected way (for me) on Linux.
Part of the script simply checks that the files generated by a build stage hasn't been manually replaced with a stale file.
# load the cache from a json file
if os.path.getmtime(some_path) < cache['timestamp']:
print("build must run because %s is stale" % some_path)
run_build = true
...
if run_build:
cache['timestamp'] = time.time()
# use subprocess to run process that modifies some_path
# store updated cache to json file
Unfortunately, this naive logic isn't working on Linux (Ubuntu 16.04): the timestamp stored in the cache is often a few miliseconds ahead of the modification time on the generated files.
I could probably just round down the cached timestamp, but that just feels like a nasty hack, and I wonder if there's better way to get consistent times here.