Top-rated recipes tagged "async"http://code.activestate.com/recipes/tags/async/top/2013-10-29T16:48:22-07:00ActiveState Code RecipesAsynchronous subprocess using asyncore (Python)
2013-01-21T19:51:00-08:00Glenn Eychanerhttp://code.activestate.com/recipes/users/4172294/http://code.activestate.com/recipes/576957-asynchronous-subprocess-using-asyncore/
<p style="color: grey">
Python
recipe 576957
by <a href="/recipes/users/4172294/">Glenn Eychaner</a>
(<a href="/recipes/tags/async/">async</a>, <a href="/recipes/tags/asynchronous/">asynchronous</a>, <a href="/recipes/tags/asyncore/">asyncore</a>, <a href="/recipes/tags/coroutine/">coroutine</a>, <a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/ipc/">ipc</a>, <a href="/recipes/tags/subprocess/">subprocess</a>).
Revision 21.
</p>
<p>A coroutine-based wrapper for subprocess.Popen that uses asyncore to communicate with child processes asynchronously. This allows subprocesses to be called from within socket servers or clients without needing a complicated event loop to check both. Uses <a href="http://code.activestate.com/recipes/576965/">recipe 576965</a> to provide the asynchronous coroutine framework, <a href="http://code.activestate.com/recipes/576967/">recipe 576967</a> to provide asynchronous pipes, and <a href="http://code.activestate.com/recipes/577600/">recipe 577600</a> to provide multiple alarms.</p>
Threaded communication with subprocess (Python)
2013-03-13T06:06:16-07:00Jan Müllerhttp://code.activestate.com/recipes/users/4183984/http://code.activestate.com/recipes/578488-threaded-communication-with-subprocess/
<p style="color: grey">
Python
recipe 578488
by <a href="/recipes/users/4183984/">Jan Müller</a>
(<a href="/recipes/tags/async/">async</a>, <a href="/recipes/tags/ipc/">ipc</a>, <a href="/recipes/tags/messaging/">messaging</a>, <a href="/recipes/tags/multithreading/">multithreading</a>, <a href="/recipes/tags/pipe/">pipe</a>, <a href="/recipes/tags/queue/">queue</a>, <a href="/recipes/tags/subprocess/">subprocess</a>).
Revision 3.
</p>
<p>This recipe shows how to domesticate another executable as a service in a subprocess.</p>
Asynchronous pipe communication using asyncore (Python)
2013-10-29T16:48:22-07:00Glenn Eychanerhttp://code.activestate.com/recipes/users/4172294/http://code.activestate.com/recipes/576967-asynchronous-pipe-communication-using-asyncore/
<p style="color: grey">
Python
recipe 576967
by <a href="/recipes/users/4172294/">Glenn Eychaner</a>
(<a href="/recipes/tags/async/">async</a>, <a href="/recipes/tags/asyncore/">asyncore</a>, <a href="/recipes/tags/i_o/">i_o</a>, <a href="/recipes/tags/pipe/">pipe</a>).
Revision 9.
</p>
<p>Extends file_dispatcher to provide extra functionality for reading from and writing to pipes. Uses the observer pattern (<a href="http://code.activestate.com/recipes/576962/">recipe 576962</a>) to provide notification of new data and closed pipes.</p>
Simple threading decorator (Python)
2009-03-10T01:38:51-07:00david.gaarenstroomhttp://code.activestate.com/recipes/users/4168848/http://code.activestate.com/recipes/576684-simple-threading-decorator/
<p style="color: grey">
Python
recipe 576684
by <a href="/recipes/users/4168848/">david.gaarenstroom</a>
(<a href="/recipes/tags/async/">async</a>, <a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/run_asynchronously/">run_asynchronously</a>, <a href="/recipes/tags/thread/">thread</a>, <a href="/recipes/tags/threading/">threading</a>).
Revision 4.
</p>
<p>When you're new at threading, using threads can be a bit daunting at first. If all you want is just to "run this function in parallel (= asynchronously) to the main program code", then this recipe can be of use. Simply use "@run_async" as a decorator for the function you want to run asynchronously. A call to that function will return immediately but the function itself will run in parallel.</p>