Speed up singleton decorator so it can be used more places (#116292)
This commit is contained in:
parent
48b1678075
commit
ab2ea6100c
6 changed files with 25 additions and 28 deletions
|
@ -25,6 +25,7 @@ def singleton(data_key: str) -> Callable[[_FuncType[_T]], _FuncType[_T]]:
|
|||
"""Wrap a function with caching logic."""
|
||||
if not asyncio.iscoroutinefunction(func):
|
||||
|
||||
@functools.lru_cache(maxsize=1)
|
||||
@bind_hass
|
||||
@functools.wraps(func)
|
||||
def wrapped(hass: HomeAssistant) -> _T:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue