Ensure frontend is available if integrations fail to start - Part 1 of 2 (#36093)

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
J. Nick Koston 2020-05-28 23:09:07 -05:00 committed by GitHub
parent 9c45115468
commit fbe7b4ddfa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 173 additions and 63 deletions

View file

@ -29,6 +29,9 @@ _LOGGER = logging.getLogger(__name__)
ERROR_LOG_FILENAME = "home-assistant.log"
# How long to wait until things that run on bootstrap have to finish.
TIMEOUT_EVENT_BOOTSTRAP = 15
# hass.data key for logging information.
DATA_LOGGING = "logging"
@ -44,6 +47,13 @@ STAGE_1_INTEGRATIONS = {
"mqtt_eventstream",
# To provide account link implementations
"cloud",
# Ensure supervisor is available
"hassio",
# Get the frontend up and running as soon
# as possible so problem integrations can
# be removed
"frontend",
"config",
}
@ -399,6 +409,8 @@ async def _async_set_up_integrations(
)
if stage_1_domains:
_LOGGER.info("Setting up %s", stage_1_domains)
await async_setup_multi_components(stage_1_domains)
# Load all integrations
@ -442,4 +454,11 @@ async def _async_set_up_integrations(
# Wrap up startup
_LOGGER.debug("Waiting for startup to wrap up")
await hass.async_block_till_done()
try:
async with timeout(TIMEOUT_EVENT_BOOTSTRAP):
await hass.async_block_till_done()
except asyncio.TimeoutError:
_LOGGER.warning(
"Something is blocking Home Assistant from wrapping up the "
"bootstrap phase. We're going to continue anyway."
)