This is not a duplicate of Locking a file in Python
I have two scripts, one runs every 30 minutes, the other one runs every one minute. and they both use the same file to do few things.
at some point, every 30 minute they try to access the same file at the same time and they corrupt the file. I was thinking about using wait. but they are two independent scripts and I am not sure if this is possible.
Any idea?
I thought about using
with FileLock("document.txt")
The problem that arise is; if script-1 acquire the lock for "document.txt" then script-2 wants to access document.txt, is it going to wait that script-1 finish? or is it going to skip that line of code? as the 2nd one isn't an option? also. once the lock is acquired, how to remove it when it's no longer needed?