Ejemplo n.º 1
0
async def test_closed_unblock():
    """
    GIVEN
        Channel is open.
    WHEN
        Wait on closed, and Channel is closed while blocked.
    EXPECT
        Unblocks.
    """
    q = asyncio.Queue()
    ch = Channel(q)
    asyncio.get_running_loop().call_later(0.05, ch.close)
    await asyncio.wait_for(ch.closed(), timeout=0.1)
Ejemplo n.º 2
0
async def test_closed():
    """
    GIVEN
        Channel is open.
    WHEN
        Wait on closed.
    EXPECT
        Blocks.
    """
    q = asyncio.Queue()
    ch = Channel(q)
    with pytest.raises(asyncio.TimeoutError):
        await asyncio.wait_for(ch.closed(), timeout=0.05)