Example #1
0
 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
Example #2
0
 def coroutine_raise_meta(self):
   sched.coro_yield()
   self.coroutine_raise()
   sched.coro_yield()
Example #3
0
 def main():
   with sched.Scope() as scope:
     scope.run(lambda: incrementer(beacon), 'incrementer')
     sched.coro_yield()
     sched.coro_yield()
     raise BeaconException()
Example #4
0
 def incrementer(beacon):
   while True:
     beacon[0] += 1
     sched.coro_yield()
Example #5
0
 def waiter(beacon):
   sched.coro_yield()
   sched.coro_yield()
   sched.coro_yield()
   beacon[0] += 1
Example #6
0
 def coroutine_meta(self, n):
   self.beacon = n
   sched.coro_yield()
   self.coroutine(n + 1)
   sched.coro_yield()
   self.beacon = n + 3
Example #7
0
 def coroutine(self, n):
   self.beacon = n
   sched.coro_yield()
   self.beacon = n + 1
Example #8
0
 def coroutine2(self):
   self.beacon2 += 1
   sched.coro_yield()
   self.beacon2 += 1
Example #9
0
 def coroutine1(self):
   self.beacon1 += 1
   sched.coro_yield()
   self.beacon1 += 1