Popular recipes by Glenn Eychaner http://code.activestate.com/recipes/users/4172294/2013-10-29T16:48:22-07:00ActiveState Code RecipesQueue for managing multiple SIGALRM alarms concurrently (Python) 2012-12-06T18:58:11-08:00Glenn Eychanerhttp://code.activestate.com/recipes/users/4172294/http://code.activestate.com/recipes/577600-queue-for-managing-multiple-sigalrm-alarms-concurr/ <p style="color: grey"> Python recipe 577600 by <a href="/recipes/users/4172294/">Glenn Eychaner</a> (<a href="/recipes/tags/alarm/">alarm</a>, <a href="/recipes/tags/queue/">queue</a>, <a href="/recipes/tags/signal/">signal</a>). Revision 3. </p> <p>In asynchronous code, <em>signal.alarm()</em> is extremely useful for setting and handling timeouts and other timed and periodic tasks. It has a major limitation, however, that only one alarm function and alarm time can be set at a time; setting a new alarm disables the previous alarm. This package uses a <em>heapq</em> to maintain a queue of alarm events, allowing multiple alarm functions and alarm times to be set concurrently.</p> Asynchronous 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> 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> Flexible observer pattern implementation (Python) 2012-12-06T19:23:11-08:00Glenn Eychanerhttp://code.activestate.com/recipes/users/4172294/http://code.activestate.com/recipes/576962-flexible-observer-pattern-implementation/ <p style="color: grey"> Python recipe 576962 by <a href="/recipes/users/4172294/">Glenn Eychaner</a> (<a href="/recipes/tags/event/">event</a>, <a href="/recipes/tags/observer/">observer</a>, <a href="/recipes/tags/pattern/">pattern</a>, <a href="/recipes/tags/publish/">publish</a>, <a href="/recipes/tags/subscribe/">subscribe</a>, <a href="/recipes/tags/threadsafe/">threadsafe</a>). Revision 16. </p> <p>A simple, flexible, general-purpose observer pattern.</p> <p>Observers can be callable objects or objects with a particular named method (handle_notify() by default). Events can be any object, and observers can select which events they are interested in receiving. Support for a number of different types of lightweight event objects is included.</p> Multicontext (e.g. asynchronous) inline execution framework using coroutines (Python) 2012-12-06T19:32:20-08:00Glenn Eychanerhttp://code.activestate.com/recipes/users/4172294/http://code.activestate.com/recipes/576965-multicontext-eg-asynchronous-inline-execution-fram/ <p style="color: grey"> Python recipe 576965 by <a href="/recipes/users/4172294/">Glenn Eychaner</a> (<a href="/recipes/tags/asynchronous/">asynchronous</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/inline/">inline</a>, <a href="/recipes/tags/nonblocking/">nonblocking</a>, <a href="/recipes/tags/pattern/">pattern</a>, <a href="/recipes/tags/thread/">thread</a>). Revision 14. </p> <p>A framework for executing inline code, contained in a generator, across multiple execution contexts, by pairing it with an executor that handles the context switching at each yield. An example of a generator which executes some iterations synchronously and some asynchronously is provided. The framework is general enough to be applied to many different coroutine situations.</p>