mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Import in the executor by default for core integrations (#112127)
* Import in the executor by default for core integration * merge correct branch in * Group loading of platforms in the import executor * adjust test * remove other pr * Fix async_prepare_setup_platform test The message changed because the order changed but was not caught before merge because it required the combination of PRs to change the error message * fix * tweak * fix * self review * review * fix hue mocking * Update homeassistant/loader.py Co-authored-by: Paulus Schoutsen <balloob@gmail.com> * lint * Fix async_get_component loading in the executor when the module is already loaded The sys.modules check was incorrect (only on dev) * fix * Avoid multiple executor jobs with concurrent calls to async_get_component Return a future that can be awaited if the component is curently being loaded * adjust * coverage * coverage * concurrent platforms load test * doc strings * coverage --------- Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
parent
dd00a87ac5
commit
917f0f849d
@ -742,7 +742,10 @@ class Integration:
|
|||||||
@cached_property
|
@cached_property
|
||||||
def import_executor(self) -> bool:
|
def import_executor(self) -> bool:
|
||||||
"""Import integration in the executor."""
|
"""Import integration in the executor."""
|
||||||
return self.manifest.get("import_executor") or False
|
# If the integration does not explicitly set import_executor, we default to
|
||||||
|
# True if it's a built-in integration and False if it's a custom integration.
|
||||||
|
# In the future, we want to default to True for all integrations.
|
||||||
|
return self.manifest.get("import_executor", self.is_built_in)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def mqtt(self) -> list[str] | None:
|
def mqtt(self) -> list[str] | None:
|
||||||
|
@ -1033,6 +1033,14 @@ async def test_async_suggest_report_issue(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_import_executor_default(hass: HomeAssistant) -> None:
|
||||||
|
"""Test that import_executor defaults."""
|
||||||
|
custom_comp = mock_integration(hass, MockModule("any_random"), built_in=False)
|
||||||
|
assert custom_comp.import_executor is False
|
||||||
|
built_in_comp = mock_integration(hass, MockModule("other_random"), built_in=True)
|
||||||
|
assert built_in_comp.import_executor is True
|
||||||
|
|
||||||
|
|
||||||
async def test_config_folder_not_in_path(hass):
|
async def test_config_folder_not_in_path(hass):
|
||||||
"""Test that config folder is not in path."""
|
"""Test that config folder is not in path."""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user