From 4c11371898995944ad738cb7a52211de7c0e1f46 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 16 Feb 2024 10:13:35 -0600 Subject: [PATCH] Adjust ConfigEntry.async_setup comments to be more clear (#110726) --- homeassistant/config_entries.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/homeassistant/config_entries.py b/homeassistant/config_entries.py index 8f8d9132137..3a07804afe3 100644 --- a/homeassistant/config_entries.py +++ b/homeassistant/config_entries.py @@ -512,16 +512,19 @@ class ConfigEntry: ) result = False + # + # After successfully calling async_setup_entry, it is important that this function + # does not yield to the event loop by using `await` or `async with` or + # similar until after the state has been set by calling self._async_set_state. + # + # Otherwise we risk that any `call_soon`s + # created by an integration will be executed before the state is set. + # + # Only store setup result as state if it was not forwarded. if not domain_is_integration: return - # - # It is important that this function does not yield to the - # event loop by using `await` or `async with` or similar until - # after the state has been set. Otherwise we risk that any `call_soon`s - # created by an integration will be executed before the state is set. - # if result: self._async_set_state(hass, ConfigEntryState.LOADED, None) else: