Popular recipes tagged "multiprocessing" but not "stat"http://code.activestate.com/recipes/tags/multiprocessing-stat/2016-01-30T00:40:20-08:00ActiveState Code RecipesNondurableLogger class for use with concurrent.futures.ProcessPoolExecutor's submit and map methods (Python) 2014-02-10T17:50:59-08:00Peter Santorohttp://code.activestate.com/recipes/users/4189027/http://code.activestate.com/recipes/578827-nondurablelogger-class-for-use-with-concurrentfutu/ <p style="color: grey"> Python recipe 578827 by <a href="/recipes/users/4189027/">Peter Santoro</a> (<a href="/recipes/tags/logging/">logging</a>, <a href="/recipes/tags/multiprocessing/">multiprocessing</a>). Revision 2. </p> <p>I needed a simple logging solution that I could use with with concurrent.futures.ProcessPoolExecutor and this is my initial recipe.</p> A Python chat program using process intercommunication (Python) 2012-09-12T10:02:21-07:00Chaobin Tang (唐超斌)http://code.activestate.com/recipes/users/4174076/http://code.activestate.com/recipes/578260-a-python-chat-program-using-process-intercommunica/ <p style="color: grey"> Python recipe 578260 by <a href="/recipes/users/4174076/">Chaobin Tang (唐超斌)</a> (<a href="/recipes/tags/multiprocessing/">multiprocessing</a>). </p> <p>This demo chat program, at some aspect, mimic the way that Erlang makes a distributable application. Because it utilizes process, the CPU cores are used as much as possible.</p> timeout decorator (with multiprocessing) (Python) 2011-08-23T05:25:09-07:00matt harrisonhttp://code.activestate.com/recipes/users/4179061/http://code.activestate.com/recipes/577853-timeout-decorator-with-multiprocessing/ <p style="color: grey"> Python recipe 577853 by <a href="/recipes/users/4179061/">matt harrison</a> (<a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/decorators/">decorators</a>, <a href="/recipes/tags/multiprocessing/">multiprocessing</a>, <a href="/recipes/tags/timeout/">timeout</a>). </p> <p>Given that threads shouldn't be killed, multiprocessing is one mechanism for limiting time on a potentially long running computation.</p> Multiprocessing import wrapper (Python) 2011-08-23T22:11:42-07:00Matt Keranenhttp://code.activestate.com/recipes/users/38288/http://code.activestate.com/recipes/577856-multiprocessing-import-wrapper/ <p style="color: grey"> Python recipe 577856 by <a href="/recipes/users/38288/">Matt Keranen</a> (<a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/etl/">etl</a>, <a href="/recipes/tags/import/">import</a>, <a href="/recipes/tags/multiprocessing/">multiprocessing</a>). Revision 2. </p> <p>A script used to launch multiple import scripts using the multiprocessing module. Developed to parallelize loading of multiple log files into a database for aggregate analysis</p> Simple way to execute multiple process in parallel (Python) 2010-08-31T00:11:00-07:00Benjamin Sergeanthttp://code.activestate.com/recipes/users/4039626/http://code.activestate.com/recipes/577376-simple-way-to-execute-multiple-process-in-parallel/ <p style="color: grey"> Python recipe 577376 by <a href="/recipes/users/4039626/">Benjamin Sergeant</a> (<a href="/recipes/tags/multiprocessing/">multiprocessing</a>, <a href="/recipes/tags/process/">process</a>). Revision 4. </p> <p>Does not require multiprocessing, easy to hack, maybe not optimal but did the job for a make like tool I wrote.</p> Blocking, Polling, Pipes, Queues in multiprocessing and how they are affected by the OS's time-slicing schedule (Python) 2010-05-08T18:18:01-07:00Kaushik Ghosehttp://code.activestate.com/recipes/users/4166965/http://code.activestate.com/recipes/577223-blocking-polling-pipes-queues-in-multiprocessing-a/ <p style="color: grey"> Python recipe 577223 by <a href="/recipes/users/4166965/">Kaushik Ghose</a> (<a href="/recipes/tags/events/">events</a>, <a href="/recipes/tags/multiprocessing/">multiprocessing</a>, <a href="/recipes/tags/multitasking/">multitasking</a>, <a href="/recipes/tags/polling/">polling</a>, <a href="/recipes/tags/timeslice/">timeslice</a>). </p> <p>This short code demonstrates how blocking calls to a Queue, while consuming less CPU, are limited in their response time by the minimum time slice the OS is willing to allocate (typically 10ms for Mac OS X and Linux). Non-blocking calls to Pipe, using poll() to check if there is data, on the other hand, give us millisecond or less response times, though they consume more CPU. In this respect doing a blocking call to a CPU is no different than adding sleep(.01) statements to a polling loop. In a way, if you execute a sleep(.01) only when you have no events in your poll you will be more efficient than if you had a blocking call pull events off your Queue one by one - because each call to Queue.get() consumes a time-slice, whereas the sleep(.01) only occurs once. </p> Decoupled Proxy of a State Bearing Object in a Multiprocessing Environment (Python) 2010-04-08T04:36:05-07:00Mateyuzohttp://code.activestate.com/recipes/users/4172453/http://code.activestate.com/recipes/577180-decoupled-proxy-of-a-state-bearing-object-in-a-mul/ <p style="color: grey"> Python recipe 577180 by <a href="/recipes/users/4172453/">Mateyuzo</a> (<a href="/recipes/tags/access/">access</a>, <a href="/recipes/tags/multiprocessing/">multiprocessing</a>, <a href="/recipes/tags/process/">process</a>, <a href="/recipes/tags/processing/">processing</a>, <a href="/recipes/tags/subprocess/">subprocess</a>, <a href="/recipes/tags/synchronization/">synchronization</a>, <a href="/recipes/tags/syncmanager/">syncmanager</a>, <a href="/recipes/tags/threading/">threading</a>, <a href="/recipes/tags/__getattribute__/">__getattribute__</a>). Revision 2. </p> <p>Describes a simple example of the potential for shared Singleton or Borg object methods to be proxy'd by an object that SyncManger can present to requesting subprocesses.</p> Parallelize your shell commands (Bash) 2010-04-02T00:14:38-07:00Kevin L. Sitzehttp://code.activestate.com/recipes/users/4173535/http://code.activestate.com/recipes/577171-parallelize-your-shell-commands/ <p style="color: grey"> Bash recipe 577171 by <a href="/recipes/users/4173535/">Kevin L. Sitze</a> (<a href="/recipes/tags/fifo/">fifo</a>, <a href="/recipes/tags/multiprocessing/">multiprocessing</a>, <a href="/recipes/tags/parallel/">parallel</a>). Revision 2. </p> <p>This script is used to processes a batch job of commands in parallel. The script dispatches new commands up to a user specified limit, each generated from a template provided on the command line using arguments taken from STDIN. The basic combining semantics are similar to "xargs -1", though support for multiple arguments and parallel processing of commands are provided.</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> CallPipe: Call the methods of an object in a remote process (Python) 2008-09-17T17:33:36-07:00david decotignyhttp://code.activestate.com/recipes/users/4129454/http://code.activestate.com/recipes/576509-callpipe-call-the-methods-of-an-object-in-a-remote/ <p style="color: grey"> Python recipe 576509 by <a href="/recipes/users/4129454/">david decotigny</a> (<a href="/recipes/tags/call/">call</a>, <a href="/recipes/tags/multiprocessing/">multiprocessing</a>, <a href="/recipes/tags/pipe/">pipe</a>, <a href="/recipes/tags/processing/">processing</a>, <a href="/recipes/tags/remote/">remote</a>). Revision 6. </p> <p>I am process A and I own object Obj. Now I decide to fork(): process B is born.</p> <p>How do I do to make process B call the methods of A's object Obj (and not the methods of its own copy of Obj...) ?</p> <p>This is what this module does: you create the "CallPipe" for Obj prior to fork()ing, and then process B can call any method of A's object Obj through it.</p>