Q: How can I lock a file in Windows?

A.Newby deathtospam43423 at altavista.com
Sat Mar 9 05:06:08 EST 2002


I am writing a cgi based, html chat script in Python. Basically, it takes 
input from people's browsers, writes it to a text file, then displays the 
contents of that file back to everyone. Simple.

Problem is I need to be able to lock the text file during the write 
procedure, so that only one person can write to it at a time. 
Unfortunately, not having access to a Unix server atm, I'm using Windows. 
That means I don't have the fcntl module, which means I can't use flock to 
lock the file. 

Is there another way I can lock the file in Windows? 

-- 
cdewin at dingoblue.net.au



More information about the Python-list mailing list