Exemplo n.º 1
0
def test_diag(kernel):
    # Test ability to get stack traces from different contexts
    from curio.task import _get_stack

    # Normal generator
    def gen(n):
        yield n

    def gen2(n):
        yield from gen(n)

    # Async generator
    async def agen(n):
        yield (await sleep(0.1))

    g = gen(0)
    next(g)
    w = _get_stack(g)

    g = gen2(0)
    next(g)
    w = _get_stack(g)

    async def f():
        a = agen(0)
        w = _get_stack(a)
        await a.asend(None)

    g = f()
    g.send(None)
    w = _get_stack(g)
Exemplo n.º 2
0
 async def f():
     a = agen(0)
     w = _get_stack(a)
     await a.asend(None)