1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-08 17:49:37 +01:00

Improve error message for global timeout (#141563)

* Improve error message for global timeout

* Add test

* Message works with zone too
This commit is contained in:
Artur Pragacz
2025-05-27 07:49:18 +02:00
committed by GitHub
parent d25ba79427
commit b36b591ccf
3 changed files with 51 additions and 7 deletions
+22
View File
@@ -36,6 +36,18 @@ async def test_simple_global_timeout_freeze() -> None:
await asyncio.sleep(0.3)
async def test_simple_global_timeout_cancel_message() -> None:
"""Test a simple global timeout cancel message."""
timeout = TimeoutManager()
with suppress(TimeoutError):
async with timeout.async_timeout(0.1, cancel_message="Test"):
with pytest.raises(
asyncio.CancelledError, match="Global task timeout: Test"
):
await asyncio.sleep(0.3)
async def test_simple_zone_timeout_freeze_inside_executor_job(
hass: HomeAssistant,
) -> None:
@@ -222,6 +234,16 @@ async def test_simple_zone_timeout() -> None:
await asyncio.sleep(0.3)
async def test_simple_zone_timeout_cancel_message() -> None:
"""Test a simple zone timeout cancel message."""
timeout = TimeoutManager()
with suppress(TimeoutError):
async with timeout.async_timeout(0.1, "test", cancel_message="Test"):
with pytest.raises(asyncio.CancelledError, match="Zone timeout: Test"):
await asyncio.sleep(0.3)
async def test_simple_zone_timeout_does_not_leak_upward(
hass: HomeAssistant,
) -> None: