forked from home-assistant/core
Close Octoprint aiohttp session on unload (#144670)
This commit is contained in:
committed by
Franck Nijhof
parent
0635856761
commit
543348fe58
@@ -181,11 +181,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
session = aiohttp.ClientSession(connector=connector)
|
||||
|
||||
@callback
|
||||
def _async_close_websession(event: Event) -> None:
|
||||
def _async_close_websession(event: Event | None = None) -> None:
|
||||
"""Close websession."""
|
||||
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(
|
||||
host=entry.data[CONF_HOST],
|
||||
|
Reference in New Issue
Block a user