From 7a9e02328e897ab3944d2dd04555307413c35bac Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 19 Jun 2023 11:11:35 -0500 Subject: [PATCH] break reference cycles --- homeassistant/components/websocket_api/http.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/homeassistant/components/websocket_api/http.py b/homeassistant/components/websocket_api/http.py index 468758fa35f85..f4682c68b5ec5 100644 --- a/homeassistant/components/websocket_api/http.py +++ b/homeassistant/components/websocket_api/http.py @@ -392,6 +392,8 @@ def handle_hass_stop(event: Event) -> None: finally: unsub_stop() + self._cancel_peak_checker() + if connection is not None: connection.async_handle_close() @@ -424,4 +426,14 @@ def handle_hass_stop(event: Event) -> None: async_dispatcher_send(self.hass, SIGNAL_WEBSOCKET_DISCONNECTED) + # Break reference cycles to make sure GC can happen sooner + self.wsock = None # type: ignore[assignment] + self.request = None # type: ignore[assignment] + self.hass = None # type: ignore[assignment] + self._logger = None # type: ignore[assignment] + self._message_queue = None # type: ignore[assignment] + self._handle_task = None + self._writer_task = None + self._ready_future = None + return wsock