def _patched_ssdp_listener(info: CaseInsensitiveDict, *args, **kwargs): listener = SsdpSearchListener(*args, **kwargs) async def _async_callback(*_): if kwargs["source"][0] == FAIL_TO_BIND_IP: raise OSError await listener.async_connect_callback() @callback def _async_search(*_): if info: asyncio.create_task(listener.async_callback(info)) listener.async_start = _async_callback listener.async_search = _async_search return listener
def _patched_ssdp_listener(info: ssdp.SsdpHeaders, *args, **kwargs): listener = SsdpSearchListener(*args, **kwargs) async def _async_callback(*_): if kwargs["source_ip"] == IPv4Address(FAIL_TO_BIND_IP): raise OSError await listener.async_connect_callback() @callback def _async_search(*_): if info: asyncio.create_task(listener.async_callback(info)) listener.async_start = _async_callback listener.async_search = _async_search return listener