home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
69.03k stars 28.28k forks source link

Turn on thread safety checks in async_dispatcher_send #116867

Closed bdraco closed 1 week ago

bdraco commented 1 week ago

Proposed change

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 or end up trying to unsafely inject a task into the loop from the wrong thread.

Since this is happening in core integrations as well, it seems worth the trade off to check these at run time for the next year.

Type of change

Additional information

Checklist

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

To help with the load of incoming pull requests: