Make system_log test reliable (#40049)

This commit is contained in:
J. Nick Koston 2020-09-14 01:48:59 -05:00 committed by GitHub
parent c19b5c5ac3
commit 2e1dbe51a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -211,6 +211,8 @@ async def async_setup(hass, config):
handler = LogErrorHandler(hass, conf[CONF_MAX_ENTRIES], conf[CONF_FIRE_EVENT])
hass.data[DOMAIN] = handler
listener = logging.handlers.QueueListener(
simple_queue, handler, respect_handler_level=True
)
@ -222,6 +224,7 @@ async def async_setup(hass, config):
"""Cleanup handler."""
logging.root.removeHandler(queue_handler)
listener.stop()
del hass.data[DOMAIN]
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_CLOSE, _async_stop_queue_handler)

View File

@ -31,6 +31,8 @@ async def _async_block_until_queue_empty(hass, sq):
await hass.async_block_till_done()
while not sq.empty():
await asyncio.sleep(0.01)
hass.data[system_log.DOMAIN].acquire()
hass.data[system_log.DOMAIN].release()
await hass.async_block_till_done()