mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +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)
|
||||
|
||||
@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],
|
||||
|
Loading…
x
Reference in New Issue
Block a user