def check(i): # Yield twice, to make sure lock_f has an execution slot: we # just woke him, so it might be scheduled after us in the next # round. sched.coro_yield() sched.coro_yield() assert beacon[0] == i sched.coro_yield() assert beacon[0] == i s.unlock() assert beacon[0] == i
def coroutine_raise_meta(self): sched.coro_yield() self.coroutine_raise() sched.coro_yield()
def main(): with sched.Scope() as scope: scope.run(lambda: incrementer(beacon), 'incrementer') sched.coro_yield() sched.coro_yield() raise BeaconException()
def incrementer(beacon): while True: beacon[0] += 1 sched.coro_yield()
def waiter(beacon): sched.coro_yield() sched.coro_yield() sched.coro_yield() beacon[0] += 1
def coroutine_meta(self, n): self.beacon = n sched.coro_yield() self.coroutine(n + 1) sched.coro_yield() self.beacon = n + 3
def coroutine(self, n): self.beacon = n sched.coro_yield() self.beacon = n + 1
def coroutine2(self): self.beacon2 += 1 sched.coro_yield() self.beacon2 += 1
def coroutine1(self): self.beacon1 += 1 sched.coro_yield() self.beacon1 += 1