mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Fix blocking I/O to import modules in mysensors (#116516)
This commit is contained in:
parent
082721e1ab
commit
780a6b314f
@ -10,7 +10,7 @@ import socket
|
|||||||
import sys
|
import sys
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from mysensors import BaseAsyncGateway, Message, Sensor, mysensors
|
from mysensors import BaseAsyncGateway, Message, Sensor, get_const, mysensors
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.mqtt import (
|
from homeassistant.components.mqtt import (
|
||||||
@ -24,6 +24,7 @@ from homeassistant.config_entries import ConfigEntry
|
|||||||
from homeassistant.const import CONF_DEVICE, EVENT_HOMEASSISTANT_STOP
|
from homeassistant.const import CONF_DEVICE, EVENT_HOMEASSISTANT_STOP
|
||||||
from homeassistant.core import Event, HomeAssistant, callback
|
from homeassistant.core import Event, HomeAssistant, callback
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.setup import SetupPhases, async_pause_setup
|
||||||
from homeassistant.util.unit_system import METRIC_SYSTEM
|
from homeassistant.util.unit_system import METRIC_SYSTEM
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -162,6 +163,12 @@ async def _get_gateway(
|
|||||||
) -> BaseAsyncGateway | None:
|
) -> BaseAsyncGateway | None:
|
||||||
"""Return gateway after setup of the gateway."""
|
"""Return gateway after setup of the gateway."""
|
||||||
|
|
||||||
|
with async_pause_setup(hass, SetupPhases.WAIT_IMPORT_PACKAGES):
|
||||||
|
# get_const will import a const module based on the version
|
||||||
|
# so we need to import it here to avoid it being imported
|
||||||
|
# in the event loop
|
||||||
|
await hass.async_add_import_executor_job(get_const, version)
|
||||||
|
|
||||||
if persistence_file is not None:
|
if persistence_file is not None:
|
||||||
# Interpret relative paths to be in hass config folder.
|
# Interpret relative paths to be in hass config folder.
|
||||||
# Absolute paths will be left as they are.
|
# Absolute paths will be left as they are.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user