INNER CODE UNIT · Python

_preload

3dg1luk43/ha_washdata · custom_components/ha_washdata/__init__.py:504

    def _preload() -> None:
        # pylint: disable=import-outside-toplevel
        from .ml.engine import preload_models

        preload_models()

    future = hass.data.get(ML_PRELOAD_FUTURE_KEY)
    if future is None:
        future = hass.data[ML_PRELOAD_FUTURE_KEY] = hass.async_add_import_executor_job(
            _preload
        )

    try:
        with async_pause_setup(hass, SetupPhases.WAIT_IMPORT_PACKAGES):
            # shield: a cancelled entry setup must not cancel the warm-up that
            # the other entries are waiting on.
            await asyncio.shield(future)
    except Exception:  # pylint: disable=broad-exception-caught

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…