mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Make system_log test reliable (#40049)
This commit is contained in:
parent
c19b5c5ac3
commit
2e1dbe51a4
@ -211,6 +211,8 @@ async def async_setup(hass, config):
|
|||||||
|
|
||||||
handler = LogErrorHandler(hass, conf[CONF_MAX_ENTRIES], conf[CONF_FIRE_EVENT])
|
handler = LogErrorHandler(hass, conf[CONF_MAX_ENTRIES], conf[CONF_FIRE_EVENT])
|
||||||
|
|
||||||
|
hass.data[DOMAIN] = handler
|
||||||
|
|
||||||
listener = logging.handlers.QueueListener(
|
listener = logging.handlers.QueueListener(
|
||||||
simple_queue, handler, respect_handler_level=True
|
simple_queue, handler, respect_handler_level=True
|
||||||
)
|
)
|
||||||
@ -222,6 +224,7 @@ async def async_setup(hass, config):
|
|||||||
"""Cleanup handler."""
|
"""Cleanup handler."""
|
||||||
logging.root.removeHandler(queue_handler)
|
logging.root.removeHandler(queue_handler)
|
||||||
listener.stop()
|
listener.stop()
|
||||||
|
del hass.data[DOMAIN]
|
||||||
|
|
||||||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_CLOSE, _async_stop_queue_handler)
|
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_CLOSE, _async_stop_queue_handler)
|
||||||
|
|
||||||
|
@ -31,6 +31,8 @@ async def _async_block_until_queue_empty(hass, sq):
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
while not sq.empty():
|
while not sq.empty():
|
||||||
await asyncio.sleep(0.01)
|
await asyncio.sleep(0.01)
|
||||||
|
hass.data[system_log.DOMAIN].acquire()
|
||||||
|
hass.data[system_log.DOMAIN].release()
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user