Avoid creating tasks to shutdown entity platforms (#111026)

* Avoid creating tasks to shutdown entity platforms

Nothing needed to be awaited here

* fix mocking

* missed one test
This commit is contained in:
J. Nick Koston 2024-02-20 20:10:25 -06:00 committed by GitHub
parent 98d5f2fc01
commit dc4008c518
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 10 additions and 9 deletions

View file

@ -5,7 +5,6 @@ import asyncio
from collections.abc import Callable, Iterable
from datetime import timedelta
from functools import partial
from itertools import chain
import logging
from types import ModuleType
from typing import Any, Generic
@ -394,8 +393,8 @@ class EntityComponent(Generic[_EntityT]):
entity_platform.async_prepare()
return entity_platform
async def _async_shutdown(self, event: Event) -> None:
@callback
def _async_shutdown(self, event: Event) -> None:
"""Call when Home Assistant is stopping."""
await asyncio.gather(
*(platform.async_shutdown() for platform in chain(self._platforms.values()))
)
for platform in self._platforms.values():
platform.async_shutdown()