Avoid creating tasks to register hassio panels (#111206)

panel_custom never suspends so we can avoid the overhead of
creating and scheduling tasks
e398accc3e/homeassistant/components/panel_custom/__init__.py (L74)

panel_custom.async_register_panel could be converted to a normal function but it
would be a breaking change
pull/110487/head^2
J. Nick Koston 2024-02-23 05:50:39 -10:00 committed by GitHub
parent e398accc3e
commit 3ecbd05ac0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 10 deletions

View File

@ -1,5 +1,4 @@
"""Implement the Ingress Panel feature for Hass.io Add-ons."""
import asyncio
from http import HTTPStatus
import logging
from typing import Any
@ -27,18 +26,13 @@ async def async_setup_addon_panel(hass: HomeAssistant, hassio: HassIO) -> None:
return
# Register available panels
jobs: list[asyncio.Task[None]] = []
for addon, data in panels.items():
if not data[ATTR_ENABLE]:
continue
jobs.append(
asyncio.create_task(
_register_panel(hass, addon, data), name=f"register panel {addon}"
)
)
if jobs:
await asyncio.wait(jobs)
# _register_panel never suspends and is only
# a coroutine because it would be a breaking change
# to make it a normal function
await _register_panel(hass, addon, data)
class HassIOAddonPanel(HomeAssistantView):