Popular recipes tagged "concurrency" but not "logging"http://code.activestate.com/recipes/tags/concurrency-logging/2014-06-30T20:30:57-07:00ActiveState Code RecipesNon-blocking readlines() (Python)
2014-06-30T20:30:57-07:00Zack Weinberghttp://code.activestate.com/recipes/users/4190298/http://code.activestate.com/recipes/578900-non-blocking-readlines/
<p style="color: grey">
Python
recipe 578900
by <a href="/recipes/users/4190298/">Zack Weinberg</a>
(<a href="/recipes/tags/concurrency/">concurrency</a>, <a href="/recipes/tags/input/">input</a>, <a href="/recipes/tags/line/">line</a>, <a href="/recipes/tags/nonblocking/">nonblocking</a>).
</p>
<p>A generator function which takes a file object (assumed to be some sort of pipe or socket, open for reading), and yields lines from it without blocking. If there is no input available, it will yield an endless stream of empty strings until input becomes available again; caller is responsible for not going into a busy loop. (Newlines are normalized but not stripped, so if there is actually a blank line in the input, the value yielded will be <code>'\n'</code>.) The intended use case is a thread which must respond promptly to input from a pipe, and also something else which cannot be fed to <code>select</code> (e.g. a <code>queue.Queue</code>). Note that the file object is ignored except for its <code>fileno</code>.</p>
<p>Only tested on Unix. Only tested on 3.4; ought to work with any python that has <code>bytearray</code>, <code>locale.getpreferredencoding</code>, and <code>fcntl</code>.</p>
A multithreaded, concurrent version of map() (Python)
2010-08-16T23:04:48-07:00Wai Yip Tunghttp://code.activestate.com/recipes/users/2382677/http://code.activestate.com/recipes/577360-a-multithreaded-concurrent-version-of-map/
<p style="color: grey">
Python
recipe 577360
by <a href="/recipes/users/2382677/">Wai Yip Tung</a>
(<a href="/recipes/tags/concurrency/">concurrency</a>, <a href="/recipes/tags/multithreading/">multithreading</a>, <a href="/recipes/tags/threads/">threads</a>).
</p>
<p>map() applies a function to a list of data sequentially. This is a variation to map that execute each function call concurrently in a thread.</p>
Git Shell Script to enhance inline automation script... (Bash)
2010-11-01T00:43:03-07:00Patrick Riendeauhttp://code.activestate.com/recipes/users/4175653/http://code.activestate.com/recipes/577447-git-shell-script-to-enhance-inline-automation-scri/
<p style="color: grey">
Bash
recipe 577447
by <a href="/recipes/users/4175653/">Patrick Riendeau</a>
(<a href="/recipes/tags/code/">code</a>, <a href="/recipes/tags/concurrency/">concurrency</a>, <a href="/recipes/tags/git/">git</a>, <a href="/recipes/tags/oop/">oop</a>, <a href="/recipes/tags/oriented/">oriented</a>, <a href="/recipes/tags/programs/">programs</a>, <a href="/recipes/tags/property/">property</a>, <a href="/recipes/tags/property_creation/">property_creation</a>, <a href="/recipes/tags/repository/">repository</a>, <a href="/recipes/tags/shell/">shell</a>, <a href="/recipes/tags/shelve/">shelve</a>).
</p>
<p>This tiny effort, depend from Fnct.D ActiveState no.577446 Core, also available from github <a href="http://github.com/priendeau/Fnct.d" rel="nofollow">http://github.com/priendeau/Fnct.d</a>, can develop basic methodology of implementing oriented program within uses of function re-declaration with function-parser to create both property-function to discover uses of getter-function and setter-function</p>
Fast, re-entrant, optimistic lock implemented in Cython (Python)
2010-07-27T20:25:20-07:00Stefan Behnelhttp://code.activestate.com/recipes/users/4174506/http://code.activestate.com/recipes/577336-fast-re-entrant-optimistic-lock-implemented-in-cyt/
<p style="color: grey">
Python
recipe 577336
by <a href="/recipes/users/4174506/">Stefan Behnel</a>
(<a href="/recipes/tags/concurrency/">concurrency</a>, <a href="/recipes/tags/lock/">lock</a>, <a href="/recipes/tags/locking/">locking</a>).
Revision 3.
</p>
<p>This is a C-level implementation of a fast, re-entrant, optimistic lock for CPython. It is written in Cython. Under normal conditions, it is about 10x faster than threading.RLock because it avoids all locking unless two or more threads try to acquire it at the same time. Under congestion, it is still about 10% faster than RLock due to being implemented in Cython.</p>
Generator Attributes (Python)
2010-02-18T17:23:59-08:00Longpokehttp://code.activestate.com/recipes/users/4173085/http://code.activestate.com/recipes/577057-generator-attributes/
<p style="color: grey">
Python
recipe 577057
by <a href="/recipes/users/4173085/">Longpoke</a>
(<a href="/recipes/tags/concurrency/">concurrency</a>, <a href="/recipes/tags/state/">state</a>).
</p>
<p>A decorator that creates a generator factory that creates generators that can have attributes set on them (like a normal python class).</p>
Concurrent buffer for generators (Python)
2010-05-05T22:47:33-07:00Javier Ruerehttp://code.activestate.com/recipes/users/4172765/http://code.activestate.com/recipes/576999-concurrent-buffer-for-generators/
<p style="color: grey">
Python
recipe 576999
by <a href="/recipes/users/4172765/">Javier Ruere</a>
(<a href="/recipes/tags/concurrency/">concurrency</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/iterator/">iterator</a>, <a href="/recipes/tags/threading/">threading</a>).
Revision 2.
</p>
<p>A buffer that will partially consume an iterator in the background.</p>
<p>Very useful for reading files and merging the data using the excellent <a href="http://code.activestate.com/recipes/491285/" rel="nofollow">http://code.activestate.com/recipes/491285/</a></p>
Simple lock-queue via Memcached (Python)
2008-11-19T01:32:07-08:00Tal Einathttp://code.activestate.com/recipes/users/2892534/http://code.activestate.com/recipes/576567-simple-lock-queue-via-memcached/
<p style="color: grey">
Python
recipe 576567
by <a href="/recipes/users/2892534/">Tal Einat</a>
(<a href="/recipes/tags/concurrency/">concurrency</a>, <a href="/recipes/tags/contextmanager/">contextmanager</a>, <a href="/recipes/tags/lock/">lock</a>, <a href="/recipes/tags/locking/">locking</a>, <a href="/recipes/tags/memcache/">memcache</a>, <a href="/recipes/tags/memcached/">memcached</a>, <a href="/recipes/tags/queue/">queue</a>).
</p>
<p>A simple lock-queue (FIFO) context manager implemented with <a href="http://www.danga.com/memcached/">Memcached</a>.</p>
<p>In essence this is a normal lock, where the requests to acquire the lock are granted in the order in which they were originally made. Note that requests to acquire the lock are always blocking.</p>