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 authored and GitHub committed 2019-05-14 05:57:47 +02:00
1 parent b2a1204bc5
commit 45085dd97f
7 files changed
+59 -20

No files matched your search

@@ -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."""