I’m writing to a file for another program (gnuplot) to use as input.
g = open('test.gnuplot', 'w')
g.write("[snip]")
g.close()
os.system("sleep 1")
os.system("gnuplot test.gnuplot")
If I omit the sleep 1 gnuplot generates a mangled file – seemingly because the file I just wrote isn’t “ready” yet (if I’m wrong please tell me what the real reason is).
I’m guessing there is a more elegant way to wait for the file to be ready for reading, what is it?
Try this:
And take away the
os.system("sleep 1"). I think the buffer is not yet written to the file. See the python fsync docs.