Popular recipes tagged "file_lock" but not "concurrency"http://code.activestate.com/recipes/tags/file_lock-concurrency/2010-09-22T00:11:12-07:00ActiveState Code Recipesfcntl.flock() (Unix file lock) behaviour sampling script (Python) 2010-09-22T00:11:12-07:00Jan Kaliszewskihttp://code.activestate.com/recipes/users/4172762/http://code.activestate.com/recipes/577404-fcntlflock-unix-file-lock-behaviour-sampling-scrip/ <p style="color: grey"> Python recipe 577404 by <a href="/recipes/users/4172762/">Jan Kaliszewski</a> (<a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/file_descriptor/">file_descriptor</a>, <a href="/recipes/tags/file_lock/">file_lock</a>, <a href="/recipes/tags/flock/">flock</a>, <a href="/recipes/tags/process/">process</a>, <a href="/recipes/tags/thread/">thread</a>). Revision 3. </p> <p>A quick <em>fcntl.flock(fcntl.LOCK_EX | fcntl.LOCK_NB)</em> call sampling script: with <em>one file object</em> (and descriptor) or <em>separate file objects</em> (and different descriptors) pointing to the same filesystem path -- with/without <strong>threading</strong> or <strong>forking</strong>.</p> <p>It's rather exemplum-and-educational piece of code than utility-script, unless somebody has to few slots in their memory to remember that <strong>flock</strong> is file-descriptor-tacked (then quick run of the script can save web-searching) :)</p> Application lock (Python) 2009-08-22T13:00:35-07:00Max Polkhttp://code.activestate.com/recipes/users/4171523/http://code.activestate.com/recipes/576891-application-lock/ <p style="color: grey"> Python recipe 576891 by <a href="/recipes/users/4171523/">Max Polk</a> (<a href="/recipes/tags/file_lock/">file_lock</a>, <a href="/recipes/tags/locking/">locking</a>). </p> <p>Ensures application runs only once.</p>