Ensure we do not start discovered flows until after the started event has fired (#38047)
* Ensure we do not start discovered flows until after the start event has fired This change makes zeroconf and ssdp match discovery behavior of not creating config flows until the start event has been fired. This prevents config flow creation/dependency installs for discovered config flows from competing for cpu time during startup. * Start discovery/service browser/ssdp when EVENT_HOMEASSISTANT_STARTED is fired instead of EVENT_HOMEASSISTANT_START
This commit is contained in:
1 parent
e766a119d2
commit
5cf7b1b1bc
5 files changed
+43
-10
No files matched your search
@@ -6,6 +6,7 @@ import pytest
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.bootstrap import async_setup_component
|
||||
from homeassistant.components import discovery
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_STARTED
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
||||
from tests.async_mock import patch
|
||||
@@ -36,10 +37,12 @@ def netdisco_mock():
|
||||
|
||||
async def mock_discovery(hass, discoveries, config=BASE_CONFIG):
|
||||
"""Mock discoveries."""
|
||||
result = await async_setup_component(hass, "discovery", config)
|
||||
assert result
|
||||
|
||||
await hass.async_start()
|
||||
with patch("homeassistant.components.zeroconf.async_get_instance"):
|
||||
assert await async_setup_component(hass, "discovery", config)
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_start()
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
with patch.object(discovery, "_discover", discoveries), patch(
|
||||
"homeassistant.components.discovery.async_discover", return_value=mock_coro()
|
||||
|
||||
Reference in new issue
Block a user