Exemple #1
0
async def test_mix_global_and_zone_timeout_freeze_():
    """Test a mix zone timeout freeze and global freeze."""
    timeout = TimeoutManager()

    async with timeout.async_timeout(0.2, "test"):
        async with timeout.async_freeze():
            async with timeout.async_freeze("test"):
                await asyncio.sleep(0.3)
Exemple #2
0
async def test_simple_global_timeout_freeze():
    """Test a simple global timeout freeze."""
    timeout = TimeoutManager()

    async with timeout.async_timeout(0.2):
        async with timeout.async_freeze():
            await asyncio.sleep(0.3)
Exemple #3
0
async def test_simple_zone_timeout_freeze_without_timeout():
    """Test a simple zone timeout freeze on a zone that does not have a timeout set."""
    timeout = TimeoutManager()

    async with timeout.async_timeout(0.1, "test"):
        async with timeout.async_freeze("test"):
            await asyncio.sleep(0.3)
Exemple #4
0
async def test_simple_zone_timeout_freeze():
    """Test a simple zone timeout freeze."""
    timeout = TimeoutManager()

    async with timeout.async_timeout(0.2, "test"):
        async with timeout.async_freeze("test"):
            await asyncio.sleep(0.3)
Exemple #5
0
async def test_simple_global_timeout_freeze_with_executor_job(opp):
    """Test a simple global timeout freeze with executor job."""
    timeout = TimeoutManager()

    async with timeout.async_timeout(0.2):
        async with timeout.async_freeze():
            await opp.async_add_executor_job(lambda: time.sleep(0.3))
Exemple #6
0
async def test_simple_zone_timeout_freeze_reset():
    """Test a simple zone timeout freeze reset."""
    timeout = TimeoutManager()

    with pytest.raises(asyncio.TimeoutError):
        async with timeout.async_timeout(0.2, "test"):
            async with timeout.async_freeze("test"):
                await asyncio.sleep(0.1)
            await asyncio.sleep(0.2, "test")
Exemple #7
0
async def test_simple_global_timeout_freeze_reset():
    """Test a simple global timeout freeze reset."""
    timeout = TimeoutManager()

    with pytest.raises(asyncio.TimeoutError):
        async with timeout.async_timeout(0.2):
            async with timeout.async_freeze():
                await asyncio.sleep(0.1)
            await asyncio.sleep(0.2)
Exemple #8
0
async def test_simple_zone_timeout_freeze_without_timeout_exeption():
    """Test a simple zone timeout freeze on a zone that does not have a timeout set."""
    timeout = TimeoutManager()

    with pytest.raises(asyncio.TimeoutError):
        async with timeout.async_timeout(0.1):
            with suppress(RuntimeError):
                async with timeout.async_freeze("test"):
                    raise RuntimeError()

            await asyncio.sleep(0.4)