Popular recipes tagged "meta:loc=269" but not "prototyping"http://code.activestate.com/recipes/tags/meta:loc=269-prototyping/2004-08-23T06:47:19-07:00ActiveState Code RecipesCoroutines in Python (Python)
2004-08-23T06:47:19-07:00Bernhard Mulderhttp://code.activestate.com/recipes/users/189076/http://code.activestate.com/recipes/300019-coroutines-in-python/
<p style="color: grey">
Python
recipe 300019
by <a href="/recipes/users/189076/">Bernhard Mulder</a>
.
Revision 4.
</p>
<p>This recipe shows how you can emulate coroutines in pure Python using generators.</p>
<p>With coroutine I mean a construct as available, for example, in Simula 67 or Modula2. They are like threads with two additional restrictions: at most one coroutine can be running at any time, and each coroutine yields control only at very specific points. Other terms I have heard for this concept are "cooperative multitasking", "non-preemptive multitasking" or Fibers (on Windows).</p>