Log events with no listeners (#98540)

* Log events with no listeners

* Unconditionally create the Event object

* Reformat code
This commit is contained in:
Erik Montnemery 2023-08-16 20:14:49 +02:00 committed by GitHub
parent b9203cbeaf
commit 31f5932fe4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1025,6 +1025,11 @@ class EventBus:
listeners = self._listeners.get(event_type, [])
match_all_listeners = self._match_all_listeners
event = Event(event_type, event_data, origin, time_fired, context)
if _LOGGER.isEnabledFor(logging.DEBUG):
_LOGGER.debug("Bus:Handling %s", event)
if not listeners and not match_all_listeners:
return
@ -1032,11 +1037,6 @@ class EventBus:
if event_type != EVENT_HOMEASSISTANT_CLOSE:
listeners = match_all_listeners + listeners
event = Event(event_type, event_data, origin, time_fired, context)
if _LOGGER.isEnabledFor(logging.DEBUG):
_LOGGER.debug("Bus:Handling %s", event)
for job, event_filter, run_immediately in listeners:
if event_filter is not None:
try: