The open(filename::AbstractString; lock = true, keywords...) function has a keyword lock. According to official documentation "The lock keyword argument controls whether operations will be locked for safe multi-threaded access." Even after putting lock keyword to true explicitly, I can open the same file in different a process(for testing I used 2 julia REPLs) and edit it from both process. Now, my questions are:
- What does lock keyword actually do?
- Is there any way to open a file exclusively in a process and make other processes wait for it to prevent data race?
- Even after
lock=true, can the file get corrupted if two processes try to write it at the same time? - What does "safe multi-threaded access" mean in this context?
I am using Julia 1.7.3 on linuxmint 20.3