Retry onvif setup when it is unexpectedly cancelled (#92313)
* Retry onvif setup when it is unexpectedly cancelled fixes #92308 * Retry onvif setup when it is unexpectedly cancelled fixes #92308pull/92325/head
parent
32f6dd4a82
commit
30dd8b9f3a
|
@ -1,4 +1,5 @@
|
||||||
"""The ONVIF integration."""
|
"""The ONVIF integration."""
|
||||||
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from httpx import RequestError
|
from httpx import RequestError
|
||||||
|
@ -57,6 +58,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
raise ConfigEntryNotReady(
|
raise ConfigEntryNotReady(
|
||||||
f"Could not setup camera {device.device.host}:{device.device.port}: {err}"
|
f"Could not setup camera {device.device.host}:{device.device.port}: {err}"
|
||||||
) from err
|
) from err
|
||||||
|
except asyncio.CancelledError as err:
|
||||||
|
# After https://github.com/agronholm/anyio/issues/374 is resolved
|
||||||
|
# this may be able to be removed
|
||||||
|
await device.device.close()
|
||||||
|
raise ConfigEntryNotReady(f"Setup was unexpectedly canceled: {err}") from err
|
||||||
|
|
||||||
if not device.available:
|
if not device.available:
|
||||||
raise ConfigEntryNotReady()
|
raise ConfigEntryNotReady()
|
||||||
|
|
Loading…
Reference in New Issue