def t(): while not stopall: g = Group() for i in range(5): g.spawn(f(i)) g.join() time.sleep(random.random() * 0.02)
def test_group(): timespan = 0.1 @asyncio.coroutine def f(i): t0 = time.time() yield from asyncio.sleep(timespan) t = time.time() - t0 print('finish {}, seconds={:4.2f}'.format(i, t)) print('testing group') t0 = time.time() g = Group() for i in range(9): g.spawn(f(i)) g.join() print('total time: {:4.2f}'.format(time.time() - t0)) assert timespan < time.time() - t0 < timespan * 1.1
def f2(): g = Group() for c in chars: g.spawn(f(c)) g.join()