Files question

Richard van de Stadt stadt at cs.utwente.nl
Fri Jul 14 03:53:47 EDT 2000


"Dinu C. Gherman" wrote:
> 
> sergio wrote:
> >
> >     I'm working in winNT Server 4.0.
> >     How can i know if a file is open by other apllication, in order to
> > wait till the file is free 
> Have you tried just reading a few bytes and catch the
> IOError if there is any (supposed you know the file
> does exist)? Just an (untested) idea...

OLWUC - open-lock-write-unlock-close

import posixfile
usersfile = posixfile.open (someFilename, 'a')
usersfile.lock ('w|')
usersfile.write ('something'))
usersfile.lock ('u')
usersfile.close()

Note: the 'other application' must do the same.
I assume, but am not sure, that this works for reading a file as well.

Richard.



More information about the Python-list mailing list