PHP continuously appends text to a file foo.log with mode "a". I want to read the contents of foo.log in python and truncate the lines that have been read, while avoiding concurrent access issues between python and PHP.
This answer states that os.rename is atomic on most platforms. Thus, would it be safe to accomplish my goal by simplty renaming foo.log to bar.log and then read bar.log into python? Or do I need to implement a more complex solution, such as a shared lockfile?