mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 13:57:10 +00:00
Speed up async_render_with_possible_json_value (#118080)
This commit is contained in:
parent
3416162fdb
commit
5cb3bc19c0
@ -7,7 +7,7 @@ import asyncio
|
|||||||
import base64
|
import base64
|
||||||
import collections.abc
|
import collections.abc
|
||||||
from collections.abc import Callable, Generator, Iterable
|
from collections.abc import Callable, Generator, Iterable
|
||||||
from contextlib import AbstractContextManager, suppress
|
from contextlib import AbstractContextManager
|
||||||
from contextvars import ContextVar
|
from contextvars import ContextVar
|
||||||
from datetime import date, datetime, time, timedelta
|
from datetime import date, datetime, time, timedelta
|
||||||
from functools import cache, lru_cache, partial, wraps
|
from functools import cache, lru_cache, partial, wraps
|
||||||
@ -759,8 +759,10 @@ class Template:
|
|||||||
variables = dict(variables or {})
|
variables = dict(variables or {})
|
||||||
variables["value"] = value
|
variables["value"] = value
|
||||||
|
|
||||||
with suppress(*JSON_DECODE_EXCEPTIONS):
|
try: # noqa: SIM105 - suppress is much slower
|
||||||
variables["value_json"] = json_loads(value)
|
variables["value_json"] = json_loads(value)
|
||||||
|
except JSON_DECODE_EXCEPTIONS:
|
||||||
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
render_result = _render_with_context(
|
render_result = _render_with_context(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user