Locking a file under Windows

Guy Lateur guy.lateur at b-b.be
Thu Nov 24 11:19:34 EST 2005


Thank you, Tim.

The portalocker code seems to prevent reading while the file is locked for 
writing, but it doesn't seem to prevent multiple writes (nor multiple 
exclusive locks, for that matter).

I guess it'd be better if I use the second suggestion, i.e. temporarily 
renaming the file for writing, and renaming it back to unlock it.

Cheers,
g



"Tim Golden" <tim.golden at viacom-outdoor.co.uk> schreef in bericht 
news:mailman.1160.1132845093.18701.python-list at python.org...

Might be worth looking in the Python Cookbook area. I seem
to remember several recipes to do this kind of thing
cross-platform. eg,

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65203

Also the pywin32 docs come with a flock-style example. Hope
one of the two can help you.

TJG





More information about the Python-list mailing list