From f0e11f713ed246ab9aa5a4840421172c56bb728d Mon Sep 17 00:00:00 2001 From: Robert Svensson Date: Mon, 26 Oct 2020 22:12:21 +0100 Subject: [PATCH] Make sure to clean up httpx session on failed connection to Axis device (#42428) --- homeassistant/components/axis/device.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/homeassistant/components/axis/device.py b/homeassistant/components/axis/device.py index 94aa149c09e..79204bf3002 100644 --- a/homeassistant/components/axis/device.py +++ b/homeassistant/components/axis/device.py @@ -280,12 +280,15 @@ async def get_device(hass, host, port, username, password): except axis.Unauthorized as err: LOGGER.warning("Connected to device at %s but not registered.", host) + await device.vapix.close() raise AuthenticationRequired from err except (asyncio.TimeoutError, axis.RequestError) as err: LOGGER.error("Error connecting to the Axis device at %s", host) + await device.vapix.close() raise CannotConnect from err except axis.AxisException as err: LOGGER.exception("Unknown Axis communication error occurred") + await device.vapix.close() raise AuthenticationRequired from err