I have a device which I am controlling in a for loop. I would like to check every iteration if a .txt file has changed. If it has I want to read values and send them to the device. I am checking if file was updated like this:
os.stat("myfile.txt").stat.st_mtime
This is working fine when I manually open file, write values and save file.
I want to change values by another Python script which will be run by another process. In this other script I write values to the .txt file like this:
text_file = open("myfile.txt", 'w')
text_file.write("\n0\n0\n0")
text_file.close()
When I call open(), st_mtime changes and I load nothing because text file is empty. How to deal with this? Are there other approaches besides a text file to set new values by another Python process?