Cache is_official_image/is_docker_env in bootstrap to fix blocking I/O (#121261)
* Cache is_official_image and is_docker_env in bootstrap to fix blocking I/O These do blocking I/O later in the startup process discovered in https://github.com/home-assistant/core/pull/120273 * comment
This commit is contained in:
parent
6c42596bdd
commit
adee8094e7
1 changed files with 6 additions and 2 deletions
|
@ -88,7 +88,7 @@ from .helpers import (
|
|||
)
|
||||
from .helpers.dispatcher import async_dispatcher_send_internal
|
||||
from .helpers.storage import get_internal_store_manager
|
||||
from .helpers.system_info import async_get_system_info
|
||||
from .helpers.system_info import async_get_system_info, is_official_image
|
||||
from .helpers.typing import ConfigType
|
||||
from .setup import (
|
||||
# _setup_started is marked as protected to make it clear
|
||||
|
@ -104,7 +104,7 @@ from .setup import (
|
|||
from .util.async_ import create_eager_task
|
||||
from .util.hass_dict import HassKey
|
||||
from .util.logging import async_activate_log_queue_handler
|
||||
from .util.package import async_get_user_site, is_virtual_env
|
||||
from .util.package import async_get_user_site, is_docker_env, is_virtual_env
|
||||
|
||||
with contextlib.suppress(ImportError):
|
||||
# Ensure anyio backend is imported to avoid it being imported in the event loop
|
||||
|
@ -407,6 +407,10 @@ def _init_blocking_io_modules_in_executor() -> None:
|
|||
# Initialize the mimetypes module to avoid blocking calls
|
||||
# to the filesystem to load the mime.types file.
|
||||
mimetypes.init()
|
||||
# Initialize is_official_image and is_docker_env to avoid blocking calls
|
||||
# to the filesystem.
|
||||
is_official_image()
|
||||
is_docker_env()
|
||||
|
||||
|
||||
async def async_load_base_functionality(hass: core.HomeAssistant) -> None:
|
||||
|
|
Loading…
Add table
Reference in a new issue