Close Octoprint aiohttp session on unload (#144670)

This commit is contained in:
Ruben van Dijk 2025-05-11 21:06:04 +02:00 committed by Franck Nijhof
parent 0635856761
commit 543348fe58
No known key found for this signature in database
GPG Key ID: AB33ADACE7101952

View File

@ -181,11 +181,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
session = aiohttp.ClientSession(connector=connector) session = aiohttp.ClientSession(connector=connector)
@callback @callback
def _async_close_websession(event: Event) -> None: def _async_close_websession(event: Event | None = None) -> None:
"""Close websession.""" """Close websession."""
session.detach() session.detach()
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _async_close_websession) entry.async_on_unload(_async_close_websession)
entry.async_on_unload(
hass.bus.async_listen(EVENT_HOMEASSISTANT_STOP, _async_close_websession)
)
client = OctoprintClient( client = OctoprintClient(
host=entry.data[CONF_HOST], host=entry.data[CONF_HOST],