예제 #1
0
    def t():
        while not stopall:
            g = Group()
            for i in range(5):
                g.spawn(f(i))

            g.join()

            time.sleep(random.random() * 0.02)
예제 #2
0
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
예제 #3
0
    def f2():
        g = Group()
        for c in chars:
            g.spawn(f(c))

        g.join()