Switch yeelight to use async_timeout instead of asyncio.wait_for (#78606)

This commit is contained in:
J. Nick Koston 2022-09-17 01:35:53 -05:00 committed by GitHub
parent 5cde3ca4e1
commit 82407ca433
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)