How to check whether file is open or not

Ros pyalbert at gmail.com
Wed Mar 7 00:28:33 EST 2007


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.

How can I check whether the file is open or not?

I tried os.stat and os.access but I am not getting the expected
results.
Also I checked in IO exceptions, IO error handler doesnt raise any
error if the file is open.
There are some options to check but they are platform dependent (works
only with unix)

Your help would be highly appreciated.

Thanks,
Ros




More information about the Python-list mailing list