Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log events with no listeners #98540

Merged
merged 3 commits into from
Aug 16, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 4 additions & 5 deletions homeassistant/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,18 +1025,17 @@ def async_fire(
listeners = self._listeners.get(event_type, [])
match_all_listeners = self._match_all_listeners

event = Event(event_type, event_data, origin, time_fired, context)
frenck marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A normal setup will have a working recorder which subscribes to all events. Hence, we can unconditionally create the Event object here.

if _LOGGER.isEnabledFor(logging.DEBUG):
_LOGGER.debug("Bus:Handling %s", event)

if not listeners and not match_all_listeners:
return

# EVENT_HOMEASSISTANT_CLOSE should not be sent to MATCH_ALL listeners
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:
Expand Down