Make discovery flow tasks background tasks (#116327)
parent
5d59b4cddd
commit
76639252c9
|
@ -1157,6 +1157,7 @@ class ConfigEntriesFlowManager(data_entry_flow.FlowManager[ConfigFlowResult]):
|
|||
cooldown=DISCOVERY_COOLDOWN,
|
||||
immediate=True,
|
||||
function=self._async_discovery,
|
||||
background=True,
|
||||
)
|
||||
|
||||
async def async_wait_import_flow_initialized(self, handler: str) -> None:
|
||||
|
|
|
@ -30,7 +30,7 @@ def async_create_flow(
|
|||
|
||||
if not dispatcher or dispatcher.started:
|
||||
if init_coro := _async_init_flow(hass, domain, context, data):
|
||||
hass.async_create_task(
|
||||
hass.async_create_background_task(
|
||||
init_coro, f"discovery flow {domain} {context}", eager_start=True
|
||||
)
|
||||
return
|
||||
|
|
|
@ -103,7 +103,7 @@ async def test_bluetooth(
|
|||
|
||||
# Inject the service info will trigger the flow to start
|
||||
inject_bluetooth_service_info(hass, WATER_TIMER_SERVICE_INFO)
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
result = next(iter(hass.config_entries.flow.async_progress_by_handler(DOMAIN)))
|
||||
|
||||
|
|
|
@ -1098,7 +1098,7 @@ async def test_setup_hardware_integration(
|
|||
) as mock_setup_entry,
|
||||
):
|
||||
result = await async_setup_component(hass, "hassio", {"hassio": {}})
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
assert result
|
||||
assert aioclient_mock.call_count == 19
|
||||
|
|
|
@ -44,7 +44,7 @@ async def test_setup_entry(
|
|||
),
|
||||
):
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
assert len(mock_get_os_info.mock_calls) == 1
|
||||
|
||||
|
@ -90,7 +90,7 @@ async def test_setup_zha(hass: HomeAssistant, addon_store_info) -> None:
|
|||
),
|
||||
):
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
assert len(mock_get_os_info.mock_calls) == 1
|
||||
|
||||
# Finish setting up ZHA
|
||||
|
@ -144,7 +144,7 @@ async def test_setup_zha_multipan(
|
|||
),
|
||||
):
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
assert len(mock_get_os_info.mock_calls) == 1
|
||||
|
||||
# Finish setting up ZHA
|
||||
|
@ -198,7 +198,7 @@ async def test_setup_zha_multipan_other_device(
|
|||
),
|
||||
):
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
assert len(mock_get_os_info.mock_calls) == 1
|
||||
|
||||
# Finish setting up ZHA
|
||||
|
|
|
@ -722,7 +722,7 @@ async def test_integration_discovery(hass: HomeAssistant) -> None:
|
|||
|
||||
with patch("homeassistant.components.plex.config_flow.GDM", return_value=mock_gdm):
|
||||
await config_flow.async_discover(hass)
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
flows = hass.config_entries.flow.async_progress()
|
||||
|
||||
|
|
Loading…
Reference in New Issue