Speed up live history setup if there is no pending data to commit (#86942)
This commit is contained in:
parent
f874258e7e
commit
00118a6f96
2 changed files with 7 additions and 0 deletions
|
@ -1044,6 +1044,8 @@ class Recorder(threading.Thread):
|
|||
|
||||
async def async_block_till_done(self) -> None:
|
||||
"""Async version of block_till_done."""
|
||||
if self._queue.empty() and not self._event_session_has_pending_writes():
|
||||
return
|
||||
event = asyncio.Event()
|
||||
self.queue_task(SynchronizeTask(event))
|
||||
await event.wait()
|
||||
|
|
|
@ -2303,6 +2303,11 @@ async def test_recorder_is_far_behind(recorder_mock, hass, hass_ws_client, caplo
|
|||
hass.bus.async_fire("mock_event", {"device_id": device.id, "message": "1"})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
msg = await asyncio.wait_for(websocket_client.receive_json(), 2)
|
||||
assert msg["id"] == 7
|
||||
assert msg["type"] == "event"
|
||||
assert msg["event"]["events"] == []
|
||||
|
||||
msg = await asyncio.wait_for(websocket_client.receive_json(), 2)
|
||||
assert msg["id"] == 7
|
||||
assert msg["type"] == "event"
|
||||
|
|
Loading…
Add table
Reference in a new issue