<div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">> I am trying to find on the web how to lock a file with python in Linux.<br>> I am trying to process a group of files that are continually being
<br>> written to and when I am working on one file I would like to be able to<br>> 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> <a href="http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65203">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>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><br>Pat Martin