Adjust ConfigEntry.async_setup comments to be more clear (#110726)

This commit is contained in:
J. Nick Koston 2024-02-16 10:13:35 -06:00 committed by GitHub
parent ef9f117baa
commit 4c11371898
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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: