mirror of
https://github.com/home-assistant/core.git
synced 2025-04-28 03:07:50 +00:00
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
This commit is contained in:
parent
e398accc3e
commit
3ecbd05ac0
@ -1,5 +1,4 @@
|
|||||||
"""Implement the Ingress Panel feature for Hass.io Add-ons."""
|
"""Implement the Ingress Panel feature for Hass.io Add-ons."""
|
||||||
import asyncio
|
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
@ -27,18 +26,13 @@ async def async_setup_addon_panel(hass: HomeAssistant, hassio: HassIO) -> None:
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Register available panels
|
# Register available panels
|
||||||
jobs: list[asyncio.Task[None]] = []
|
|
||||||
for addon, data in panels.items():
|
for addon, data in panels.items():
|
||||||
if not data[ATTR_ENABLE]:
|
if not data[ATTR_ENABLE]:
|
||||||
continue
|
continue
|
||||||
jobs.append(
|
# _register_panel never suspends and is only
|
||||||
asyncio.create_task(
|
# a coroutine because it would be a breaking change
|
||||||
_register_panel(hass, addon, data), name=f"register panel {addon}"
|
# to make it a normal function
|
||||||
)
|
await _register_panel(hass, addon, data)
|
||||||
)
|
|
||||||
|
|
||||||
if jobs:
|
|
||||||
await asyncio.wait(jobs)
|
|
||||||
|
|
||||||
|
|
||||||
class HassIOAddonPanel(HomeAssistantView):
|
class HassIOAddonPanel(HomeAssistantView):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user