mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Don't use executor in send_big_result (#75427)
This commit is contained in:
parent
b6d235c0c2
commit
6b60fb9541
@ -804,7 +804,7 @@ async def websocket_camera_thumbnail(
|
|||||||
_LOGGER.warning("The websocket command 'camera_thumbnail' has been deprecated")
|
_LOGGER.warning("The websocket command 'camera_thumbnail' has been deprecated")
|
||||||
try:
|
try:
|
||||||
image = await async_get_image(hass, msg["entity_id"])
|
image = await async_get_image(hass, msg["entity_id"])
|
||||||
await connection.send_big_result(
|
connection.send_big_result(
|
||||||
msg["id"],
|
msg["id"],
|
||||||
{
|
{
|
||||||
"content_type": image.content_type,
|
"content_type": image.content_type,
|
||||||
|
@ -38,7 +38,7 @@ def _handle_errors(func):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if msg is not None:
|
if msg is not None:
|
||||||
await connection.send_big_result(msg["id"], result)
|
connection.send_big_result(msg["id"], result)
|
||||||
else:
|
else:
|
||||||
connection.send_result(msg["id"], result)
|
connection.send_result(msg["id"], result)
|
||||||
|
|
||||||
|
@ -1164,7 +1164,7 @@ async def websocket_handle_thumbnail(hass, connection, msg):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
await connection.send_big_result(
|
connection.send_big_result(
|
||||||
msg["id"],
|
msg["id"],
|
||||||
{
|
{
|
||||||
"content_type": content_type,
|
"content_type": content_type,
|
||||||
|
@ -54,12 +54,9 @@ class ActiveConnection:
|
|||||||
"""Send a result message."""
|
"""Send a result message."""
|
||||||
self.send_message(messages.result_message(msg_id, result))
|
self.send_message(messages.result_message(msg_id, result))
|
||||||
|
|
||||||
async def send_big_result(self, msg_id: int, result: Any) -> None:
|
def send_big_result(self, msg_id: int, result: Any) -> None:
|
||||||
"""Send a result message that would be expensive to JSON serialize."""
|
"""Send a result message that would be expensive to JSON serialize."""
|
||||||
content = await self.hass.async_add_executor_job(
|
self.send_message(JSON_DUMP(messages.result_message(msg_id, result)))
|
||||||
JSON_DUMP, messages.result_message(msg_id, result)
|
|
||||||
)
|
|
||||||
self.send_message(content)
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def send_error(self, msg_id: int, code: str, message: str) -> None:
|
def send_error(self, msg_id: int, code: str, message: str) -> None:
|
||||||
|
@ -17,8 +17,8 @@ async def test_send_big_result(hass, websocket_client):
|
|||||||
|
|
||||||
@websocket_api.websocket_command({"type": "big_result"})
|
@websocket_api.websocket_command({"type": "big_result"})
|
||||||
@websocket_api.async_response
|
@websocket_api.async_response
|
||||||
async def send_big_result(hass, connection, msg):
|
def send_big_result(hass, connection, msg):
|
||||||
await connection.send_big_result(msg["id"], {"big": "result"})
|
connection.send_big_result(msg["id"], {"big": "result"})
|
||||||
|
|
||||||
websocket_api.async_register_command(hass, send_big_result)
|
websocket_api.async_register_command(hass, send_big_result)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user