How to check whether file is open or not

Bart Ogryczak B.Ogryczak at gmail.com
Thu Mar 8 09:10:42 EST 2007


On Mar 7, 6:28 am, "Ros" <pyalb... at gmail.com> wrote:
> There are 10 files in the folder. I wish to process all the files one
> by one. But if the files are open or some processing is going on them
> then I do not want to disturb that process. In that case I would
> ignore processing that particular file and move to next file.

If you can os.open() with O_EXLOCK flag, it's not open by other
process. Now that should work on Unix, Linux and MacOS X. All Windows
proceeding form NT line, are supposed to be POSIX compatible, but
somehow this flag is not available.








More information about the Python-list mailing list