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 #92308
pull/92325/head
J. Nick Koston 2023-04-30 22:12:01 -05:00 committed by GitHub
parent 32f6dd4a82
commit 30dd8b9f3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

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