def g(nrec, t, count=0): t.count = count if nrec < 0: raise ValueError if nrec: g(nrec - 1, t, count + 1) Coroutine.getmain().switch()
def g(nrec, t, count=0): t.count = count if nrec < 0: raise ValueError if nrec: g(nrec-1, t, count+1) Coroutine.getmain().switch()
def f(): assert Coroutine.getmain().frame is None coro_g = self.Coroutine() coro_g.__name__ = 'coro_g' thunk_g = T(g, 42) coro_g.bind(thunk_g) coro_g.switch() res = thunk_g.count res *= 10 res |= coro_g.frame is not None # testing kill coro_g.kill() res *= 10 res |= coro_g.frame is None coro_g = self.Coroutine() # see what happens if we __del__ thunk_g = T(g, -42) coro_g.bind(thunk_g) try: coro_g.switch() except ValueError: res += 500 return res
def f(): assert Coroutine.getmain().frame is None coro_g = self.Coroutine() coro_g.__name__ = 'coro_g' thunk_g = T(g, 42) coro_g.bind(thunk_g) coro_g.switch() res = thunk_g.count res *= 10 res |= coro_g.frame is not None # testing kill coro_g.kill() res *= 10 res |= coro_g.frame is None coro_g = self.Coroutine() # see what happens if we __del__ thunk_g = T(g, -42) coro_g.bind(thunk_g) try: coro_g.switch() except ValueError: res += 500 return res
def call(self): self.result = self.consume(self.tree) Coroutine.getmain().switch()
def call(self): self.result = self.consume(self.tree) Coroutine.getmain().switch()