<br><br><div><span class="gmail_quote">On 2/22/06, <b class="gmail_sendername">Pat Martin</b> &lt;<a href="mailto:wpmartin@gmail.com">wpmartin@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<span class="q"><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">&gt; I am trying to find on the web how to lock a file with python in Linux.
<br>&gt; I am trying to process a group of files that are continually being
<br>&gt; written to and when I am working on one file I would like to be able to<br>&gt; lock it. Can anyone point me in the right direction for that.<br><br>Hi Pat,<br><br>Take a look at the 'portalocker' recipe in the Python Cookbook:
<br><br>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65203" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65203</a>
<br><br>Does this address your question?<br><br><br><br>Good luck to you!
<br></blockquote></div><br></span>I had actually looked at that site, but when I do the commands<br clear="all"><br>testfile = open('testlock', 'a+')<br>fcntl.flock(mboxfile.fileno(), fcntl.LOCK_EX)<br><br>in the interpreter and then try to access the file in another terminal (I leave the interpreter open) I can write to the file just fine with vi. So I am not thinking it is working. Unless I am missing something...
<br><br>Thanks again.<br><span class="sg"><br>Pat Martin

</span></blockquote></div><br>Ooops the commands I am running are actually <br clear="all"><br>mboxfile = open('testlock', 'a+')<br>fcntl.flock(mboxfile.fileno(), fcntl.LOCK_EX)<br><br>and it is not working. The two filenames do match, sorry for that typo earlier.
<br>-- <br>Pat Martin