mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
Fix local_todo blocking the event loop (#116473)
This commit is contained in:
parent
23a8b29bfe
commit
6c446b4e59
@ -18,6 +18,7 @@ from homeassistant.config_entries import ConfigEntry
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.setup import SetupPhases, async_pause_setup
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
from .const import CONF_TODO_LIST_NAME, DOMAIN
|
from .const import CONF_TODO_LIST_NAME, DOMAIN
|
||||||
@ -67,9 +68,16 @@ async def async_setup_entry(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Set up the local_todo todo platform."""
|
"""Set up the local_todo todo platform."""
|
||||||
|
|
||||||
store = hass.data[DOMAIN][config_entry.entry_id]
|
store: LocalTodoListStore = hass.data[DOMAIN][config_entry.entry_id]
|
||||||
ics = await store.async_load()
|
ics = await store.async_load()
|
||||||
calendar = IcsCalendarStream.calendar_from_ics(ics)
|
|
||||||
|
with async_pause_setup(hass, SetupPhases.WAIT_IMPORT_PACKAGES):
|
||||||
|
# calendar_from_ics will dynamically load packages
|
||||||
|
# the first time it is called, so we need to do it
|
||||||
|
# in a separate thread to avoid blocking the event loop
|
||||||
|
calendar: Calendar = await hass.async_add_import_executor_job(
|
||||||
|
IcsCalendarStream.calendar_from_ics, ics
|
||||||
|
)
|
||||||
migrated = _migrate_calendar(calendar)
|
migrated = _migrate_calendar(calendar)
|
||||||
calendar.prodid = PRODID
|
calendar.prodid = PRODID
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user