Add comment to ConfigEntry.async_setup about race safety (#107756)

pull/107758/head
J. Nick Koston 2024-01-10 13:03:09 -10:00 committed by GitHub
parent 1bb76e2351
commit b2f7fd12a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -478,6 +478,12 @@ class ConfigEntry:
if self.domain != integration.domain:
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: