Co-routine tail spinning
<p>Could I connect two coroutines A and B that A would excite B and B would excite A? For example, A would accept a number, print it and invoke B with (number+1). B would print it and invoke A with (number+1). I would expect 1,2,3,4,5,... printed </p>

<p>This code unfortunately does work as intended</p>

<pre><code>def coroutine(func):
    def start(*args,**kwargs):
        cr = func(*args,**kwargs)
        cr.next()
        return cr
    return start

_target_from_a = None
_target_from_b = None

@coroutine
def func_a():
    while True:
        item = yield
        print 'a', item
        _target_from_a.send(item + 1)

@coroutine
def func_b():
    while True:
        item = yield
        print 'b', item
        _target_from_b.send(item + 1)

a = func_a()
b = func_b()
_target_from_a = b
_target_from_b = a

a.send(1)
</code></pre>

<p>it produces the followng <a href="http://www.python.org/dev/peps/pep-0255/" rel="nofollow">error</a>:</p>

<pre><code>a 1
b 2
Traceback (most recent call last):
  File "coloop.py", line 31, in &lt;module&gt;
    a.send(1)
  File "coloop.py", line 17, in func_a
    _target_from_a.send(item + 1)
  File "coloop.py", line 24, in func_b
    _target_from_b.send(item + 1)
ValueError: generator already executing
</code></pre>
