Log which task is blocking startup when debug logging is on (#38134)
* Log which task is blocking startup when debug logging for homeassistant.core is on * test needs to go one level deeper now
This commit is contained in:
1 parent
24b8545ebe
commit
979dafd0a7
3 files changed
+39
-3
No files matched your search
@@ -188,8 +188,8 @@ async def test_platform_warn_slow_setup(hass):
|
||||
assert mock_call.called
|
||||
|
||||
# mock_calls[0] is the warning message for component setup
|
||||
# mock_calls[5] is the warning message for platform setup
|
||||
timeout, logger_method = mock_call.mock_calls[5][1][:2]
|
||||
# mock_calls[6] is the warning message for platform setup
|
||||
timeout, logger_method = mock_call.mock_calls[6][1][:2]
|
||||
|
||||
assert timeout == entity_platform.SLOW_SETUP_WARNING
|
||||
assert logger_method == _LOGGER.warning
|
||||
|
||||
@@ -1393,3 +1393,24 @@ async def test_start_events(hass):
|
||||
EVENT_HOMEASSISTANT_STARTED,
|
||||
]
|
||||
assert core_states == [ha.CoreState.starting, ha.CoreState.running]
|
||||
|
||||
|
||||
async def test_log_blocking_events(hass, caplog):
|
||||
"""Ensure we log which task is blocking startup when debug logging is on."""
|
||||
caplog.set_level(logging.DEBUG)
|
||||
|
||||
async def _wait_a_bit_1():
|
||||
await asyncio.sleep(0.1)
|
||||
|
||||
async def _wait_a_bit_2():
|
||||
await asyncio.sleep(0.1)
|
||||
|
||||
hass.async_create_task(_wait_a_bit_1())
|
||||
await hass.async_block_till_done()
|
||||
|
||||
with patch.object(ha, "BLOCK_LOG_TIMEOUT", 0.00001):
|
||||
hass.async_create_task(_wait_a_bit_2())
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert "_wait_a_bit_2" in caplog.text
|
||||
assert "_wait_a_bit_1" not in caplog.text
|
||||
Reference in new issue
Block a user