How to programmatically discern whether or not a file is use

Techead techead at technetos.com
Sat May 31 11:41:21 EDT 2003


How can a Python program determine whether or not a file
is use by another process?  I was hoping to locate a function
in the standard Python distribution but so far have come up
blank.

Need for the program to be able to call a function with a path
as the parameter.  It should return a value that will indicate
if the file is open or closed like this:


if  isopen( path_to_my_file ):
  print "Sorry, file is already opened by another process."


On the side, is there a way to have a similar function return
the UID of the account that has the file open?  Or the PID of
the process that has the file open?

uid = whohas( path_to_my_file )
pid = whathas( path_to_my_file )




More information about the Python-list mailing list