2

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:

  1. What does lock keyword actually do?
  2. Is there any way to open a file exclusively in a process and make other processes wait for it to prevent data race?
  3. Even after lock=true, can the file get corrupted if two processes try to write it at the same time?
  4. What does "safe multi-threaded access" mean in this context?

I am using Julia 1.7.3 on linuxmint 20.3

1
  • For the quick reference of people who might stumble upon this in the future: here is the Discourse thread discussing this question and its solutions. Commented Aug 27, 2022 at 9:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.