def test_myself_may_not_be_me_any_more(self): import gc from _stackless import clonable counter = [0] def runner(): while 1: assert clonable.getcurrent() is coro counter[0] += 1 main.switch() main = clonable.getcurrent() coro = clonable() coro.bind(runner) coro.switch() assert counter == [1] assert clonable.getcurrent() is main coro1 = coro.clone() assert counter == [1] assert clonable.getcurrent() is main coro.switch() assert counter == [2] coro.switch() assert counter == [3] assert clonable.getcurrent() is main del coro1 gc.collect() #print "collected!" assert clonable.getcurrent() is main assert counter == [3] coro.switch() assert clonable.getcurrent() is main assert counter == [4]
def runner(): while 1: assert clonable.getcurrent() is coro counter[0] += 1 main.switch()