<!--/*SC*/DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"/*EC*/-->
<html><head><title></title><style type="text/css"><!--body{padding:1ex;margin:0px;font-family:sans-serif;font-size:small;}a[href]{color:-moz-hyperlinktext !important;text-decoration:-moz-anchor-decoration;}blockquote{margin:0;border-left:2px solid #144fae;padding-left:1em;}blockquote blockquote{border-color:#006312;}blockquote blockquote blockquote{border-color:#540000;}--></style></head><body><div style="font-family: Arial; font-size: medium;" dir="ltr"><div>Is there a way to exclusively lock a file to prevent other processes from reading it while we have it open?</div>
<div> </div>
<div>I need to cache some overflow data to disk in a temp file and I want to make sure no other processes can read the contents of this file while I'm using it.</div>
<div> </div>
<div>
<div>I tried the following using an 'append binary' mode, but I can use  NotePad to read the file while I'm using it:</div>
<div> </div>
<div>fd  = open( r'a-temp-file.dat', 'ab' )</div>
<div> </div>
</div>
<div>My environment is Python 2.6.4 (32-bit) under Windows, but I'm looking for a cross-platform solution if that's possible.</div>
<div> </div>
<div>Thanks,</div>
<div>Malcolm</div></div></body></html>