1
0
mirror of https://github.com/home-assistant/core.git synced 2026-04-25 11:19:30 +01:00

Fix bug in timeout util related to multiple global freezes (#122466)

This commit is contained in:
Erik Montnemery
2024-07-29 10:12:18 +02:00
committed by GitHub
parent 5f08883227
commit 9b497aebb4
2 changed files with 30 additions and 11 deletions

View File

@@ -338,3 +338,24 @@ async def test_simple_zone_timeout_zone_with_timeout_exeption() -> None:
raise RuntimeError
await asyncio.sleep(0.3)
async def test_multiple_global_freezes(hass: HomeAssistant) -> None:
"""Test multiple global freezes."""
timeout = TimeoutManager()
async def background(delay: float) -> None:
async with timeout.async_freeze():
await asyncio.sleep(delay)
async with timeout.async_timeout(0.1):
task = hass.async_create_task(background(0.2))
async with timeout.async_freeze():
await asyncio.sleep(0.1)
await task
async with timeout.async_timeout(0.1):
task = hass.async_create_task(background(0.2))
async with timeout.async_freeze():
await asyncio.sleep(0.3)
await task