There is a folder which contains many files in it. The users of my application will work in this folder simultaneously. This application uses Path.rglob() to loop over the files in the folder. I would like to develop a mechanism that when a file is being processed/opened by a user, this file will be automatically skipped by other users.
My questions are the following:
- Can I check the status of a file being read/opened?
- Is there a scheme which is able to solve this issue in general? Eg, using external lock file to indicate a file is being read or not.
You can use something based on:
to generate a list of all open files. You can then use the generated list to decide at runtime whether to open a file or not.