Popular recipes tagged "locking" but not "lock"http://code.activestate.com/recipes/tags/locking-lock/2011-09-28T21:45:04-07:00ActiveState Code RecipesReader-Writer lock with priority for writers (Python)
2011-09-28T21:45:04-07:00Mateusz Koboshttp://code.activestate.com/recipes/users/4178730/http://code.activestate.com/recipes/577803-reader-writer-lock-with-priority-for-writers/
<p style="color: grey">
Python
recipe 577803
by <a href="/recipes/users/4178730/">Mateusz Kobos</a>
(<a href="/recipes/tags/locking/">locking</a>, <a href="/recipes/tags/threads/">threads</a>).
Revision 2.
</p>
<p>The following class implements a reader-writer lock to use in the second readers-writers problem with python threads. In this problem, many readers can simultaneously access a share, and a writer has an exclusive access to this share. Additionally, the following constraints should be met: 1) no reader should be kept waiting if the share is currently opened for reading unless a writer is also waiting for the share, 2) no writer should be kept waiting for the share longer than absolutely necessary.</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>
Simple shelve with Linux file locking (Python)
2008-12-21T05:50:07-08:00Michael Ihdehttp://code.activestate.com/recipes/users/4168518/http://code.activestate.com/recipes/576591-simple-shelve-with-linux-file-locking/
<p style="color: grey">
Python
recipe 576591
by <a href="/recipes/users/4168518/">Michael Ihde</a>
(<a href="/recipes/tags/dynamic_method/">dynamic_method</a>, <a href="/recipes/tags/locking/">locking</a>, <a href="/recipes/tags/shelve/">shelve</a>).
</p>
<p>The shelve module is a easy way to add persistence to your application via a DBM database. However, if you have multiple reader/writer combination you need to lock the file to prevent corruption. The shelve module itself does not provide locking because it is platform specific. If you only need Linux, this simple module provide an easy way to support locking using dynamically added methods.</p>