Skip to content

Commit

Permalink
Adjust ConfigEntry.async_setup comments to be more clear (#110726)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Feb 16, 2024
1 parent ef9f117 commit 4c11371
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions homeassistant/config_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,16 +512,19 @@ async def async_setup(
)
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:
Expand Down

0 comments on commit 4c11371

Please sign in to comment.