Skip to content

Commit

Permalink
Fix local_todo blocking the event loop (#116473)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored and frenck committed May 1, 2024
1 parent 3d13345 commit c574d86
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions homeassistant/components/local_todo/todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.setup import SetupPhases, async_pause_setup
from homeassistant.util import dt as dt_util

from .const import CONF_TODO_LIST_NAME, DOMAIN
Expand Down Expand Up @@ -67,9 +68,16 @@ async def async_setup_entry(
) -> None:
"""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()
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)
calendar.prodid = PRODID

Expand Down

0 comments on commit c574d86

Please sign in to comment.