From 82407ca433b592159d459568cfa1a00bd71dfa49 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 17 Sep 2022 01:35:53 -0500 Subject: [PATCH] Switch yeelight to use async_timeout instead of asyncio.wait_for (#78606) --- homeassistant/components/yeelight/scanner.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/yeelight/scanner.py b/homeassistant/components/yeelight/scanner.py index 0b33512e315..4c0b0f69310 100644 --- a/homeassistant/components/yeelight/scanner.py +++ b/homeassistant/components/yeelight/scanner.py @@ -9,6 +9,7 @@ from ipaddress import IPv4Address import logging from urllib.parse import urlparse +import async_timeout from async_upnp_client.search import SsdpSearchListener from async_upnp_client.utils import CaseInsensitiveDict @@ -154,7 +155,8 @@ class YeelightScanner: listener.async_search((host, SSDP_TARGET[1])) with contextlib.suppress(asyncio.TimeoutError): - await asyncio.wait_for(host_event.wait(), timeout=DISCOVERY_TIMEOUT) + async with async_timeout.timeout(DISCOVERY_TIMEOUT): + await host_event.wait() self._host_discovered_events[host].remove(host_event) return self._host_capabilities.get(host)