mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 07:37:34 +00:00
Close Octoprint aiohttp session on unload (#144670)
This commit is contained in:
parent
80a04314fc
commit
554cb27703
@ -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],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user