From a79fa14ee72bf9f5d61977dfba797cece6a296f4 Mon Sep 17 00:00:00 2001 From: Mike Degatano Date: Fri, 25 Aug 2023 01:22:49 -0400 Subject: [PATCH] Don't notify listeners on CoreState.CLOSE (#4506) --- supervisor/core.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/supervisor/core.py b/supervisor/core.py index 0386bf69b..7841147d7 100644 --- a/supervisor/core.py +++ b/supervisor/core.py @@ -70,13 +70,16 @@ class Core(CoreSysAttributes): ) finally: self._state = new_state - self.sys_bus.fire_event(BusEvent.SUPERVISOR_STATE_CHANGE, new_state) - # These will be received by HA after startup has completed which won't make sense - if new_state not in STARTING_STATES: - self.sys_homeassistant.websocket.supervisor_update_event( - "info", {"state": new_state} - ) + # Don't attempt to notify anyone on CLOSE as we're about to stop the event loop + if new_state != CoreState.CLOSE: + self.sys_bus.fire_event(BusEvent.SUPERVISOR_STATE_CHANGE, new_state) + + # These will be received by HA after startup has completed which won't make sense + if new_state not in STARTING_STATES: + self.sys_homeassistant.websocket.supervisor_update_event( + "info", {"state": new_state} + ) async def connect(self): """Connect Supervisor container."""