1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Better handle large amounts of data being sent over WS (#23842)

* Better handle large amounts of data being sent over WS

* Lint
This commit is contained in:
Paulus Schoutsen
2019-05-14 05:57:47 +02:00
committed by GitHub
parent b2a1204bc5
commit 45085dd97f
7 changed files with 59 additions and 20 deletions

View File

@@ -36,6 +36,13 @@ class ActiveConnection:
"""Send a result message."""
self.send_message(messages.result_message(msg_id, result))
async def send_big_result(self, msg_id, result):
"""Send a result message that would be expensive to JSON serialize."""
content = await self.hass.async_add_executor_job(
const.JSON_DUMP, messages.result_message(msg_id, result)
)
self.send_message(content)
@callback
def send_error(self, msg_id, code, message):
"""Send a error message."""