Turn on thread safety checks in async_dispatcher_send (#116867)

* Turn on thread safety checks in async_dispatcher_send

We keep seeing issues where async_dispatcher_send is called from
a thread which means we call the callback function on the other
side in the thread as well which usually leads to a crash

* Turn on thread safety checks in async_dispatcher_send

We keep seeing issues where async_dispatcher_send is called from
a thread which means we call the callback function on the other
side in the thread as well which usually leads to a crash

* adjust
This commit is contained in:
J. Nick Koston 2024-05-05 15:29:43 -05:00 committed by GitHub
parent b41b1bb998
commit 91fa8b50cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 47 additions and 17 deletions

View file

@ -84,7 +84,7 @@ from .helpers import (
template,
translation,
)
from .helpers.dispatcher import async_dispatcher_send
from .helpers.dispatcher import async_dispatcher_send_internal
from .helpers.storage import get_internal_store_manager
from .helpers.system_info import async_get_system_info
from .helpers.typing import ConfigType
@ -700,7 +700,7 @@ class _WatchPendingSetups:
def _async_dispatch(self, remaining_with_setup_started: dict[str, float]) -> None:
"""Dispatch the signal."""
if remaining_with_setup_started or not self._previous_was_empty:
async_dispatcher_send(
async_dispatcher_send_internal(
self._hass, SIGNAL_BOOTSTRAP_INTEGRATIONS, remaining_with_setup_started
)
self._previous_was_empty = not remaining_with_setup_started