Latest recipes tagged "pool"http://code.activestate.com/recipes/tags/pool/new/2016-01-30T00:40:20-08:00ActiveState Code RecipesPython Thread Pool (Python) 2010-04-12T22:27:32-07:00Emilio Montihttp://code.activestate.com/recipes/users/4173642/http://code.activestate.com/recipes/577187-python-thread-pool/ <p style="color: grey"> Python recipe 577187 by <a href="/recipes/users/4173642/">Emilio Monti</a> (<a href="/recipes/tags/pool/">pool</a>, <a href="/recipes/tags/thread/">thread</a>). Revision 9. </p> <p>A simple Python ThreadPool based on the standard library's <a href="http://docs.python.org/library/queue.html">Queue</a> object.</p> Thread Pool (Python) 2008-11-30T05:42:59-08:00Louis RIVIEREhttp://code.activestate.com/recipes/users/4035877/http://code.activestate.com/recipes/576576-thread-pool/ <p style="color: grey"> Python recipe 576576 by <a href="/recipes/users/4035877/">Louis RIVIERE</a> (<a href="/recipes/tags/design_pattern/">design_pattern</a>, <a href="/recipes/tags/pool/">pool</a>, <a href="/recipes/tags/threads/">threads</a>, <a href="/recipes/tags/thread_pool/">thread_pool</a>). Revision 4. </p> <p>Easy to use Thread Pool with a dynamically adjustable pool size.</p> Thread pool with same API as (multi)processing.Pool (Python) 2016-01-30T00:40:20-08:00david decotignyhttp://code.activestate.com/recipes/users/4129454/http://code.activestate.com/recipes/576519-thread-pool-with-same-api-as-multiprocessingpool/ <p style="color: grey"> Python recipe 576519 by <a href="/recipes/users/4129454/">david decotigny</a> (<a href="/recipes/tags/multiprocessing/">multiprocessing</a>, <a href="/recipes/tags/pool/">pool</a>, <a href="/recipes/tags/processing/">processing</a>, <a href="/recipes/tags/thread/">thread</a>). Revision 10. </p> <p>There are probably &lt;write your guess here&gt;s of recipes presenting how to implement a pool of threads. Now that multiprocessing is becoming mainstream, this recipe takes multiprocessing.Pool as a model and re-implements it entirely with threads. Even the comments should look familiar... This recipe also adds 2 new methods: imap_async() and imap_unordered_async().</p> processing.Pool variation which allows multiple threads to send the same requests without incurring duplicate processing (Python) 2008-09-17T17:01:21-07:00david decotignyhttp://code.activestate.com/recipes/users/4129454/http://code.activestate.com/recipes/576462-processingpool-variation-which-allows-multiple-thr/ <p style="color: grey"> Python recipe 576462 by <a href="/recipes/users/4129454/">david decotigny</a> (<a href="/recipes/tags/map/">map</a>, <a href="/recipes/tags/parallel/">parallel</a>, <a href="/recipes/tags/pool/">pool</a>, <a href="/recipes/tags/processing/">processing</a>, <a href="/recipes/tags/threads/">threads</a>). Revision 3. </p> <p>processing.Pool (<a href="http://pypi.python.org/pypi/processing" rel="nofollow">http://pypi.python.org/pypi/processing</a>) is a nice tool to "parallelize" map() on multiple CPUs. However, imagine you have X threads which send the same request Pool.map(getNthPrimeNumber, [100000, 10000000, 10000]) at (almost) the same time. Obviously, you don't want to compute X times getNthPrimeNumber for 100000, 10000000, 10000... unless you have 3.X processors available. You would like one thread to submit the 3 requests, and then the X-1 others would notice that the requests have already been submitted and will then just wait for the result. This is what this code is about: a kind of "trensient memoize" for processing.Pool::imap().</p>