From 166910f587f91c5bd468df28644ce124211e611d Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 6 Apr 2024 09:53:50 -1000 Subject: [PATCH] Make eager_start default to True for async_create_background_task (#114996) --- homeassistant/components/imap/coordinator.py | 2 +- homeassistant/components/ollama/config_flow.py | 4 +++- homeassistant/components/zeroconf/__init__.py | 1 + homeassistant/core.py | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/imap/coordinator.py b/homeassistant/components/imap/coordinator.py index 997bff13534..59ceb2b3b3d 100644 --- a/homeassistant/components/imap/coordinator.py +++ b/homeassistant/components/imap/coordinator.py @@ -448,7 +448,7 @@ class ImapPushDataUpdateCoordinator(ImapDataUpdateCoordinator): async def async_start(self) -> None: """Start coordinator.""" self._push_wait_task = self.hass.async_create_background_task( - self._async_wait_push_loop(), "Wait for IMAP data push" + self._async_wait_push_loop(), "Wait for IMAP data push", eager_start=False ) async def _async_wait_push_loop(self) -> None: diff --git a/homeassistant/components/ollama/config_flow.py b/homeassistant/components/ollama/config_flow.py index 50d0667803f..4c59a38bfe0 100644 --- a/homeassistant/components/ollama/config_flow.py +++ b/homeassistant/components/ollama/config_flow.py @@ -149,7 +149,9 @@ class OllamaConfigFlow(ConfigFlow, domain=DOMAIN): # The task will block until the model and metadata are fully # downloaded. self.download_task = self.hass.async_create_background_task( - self.client.pull(self.model), f"Downloading {self.model}" + self.client.pull(self.model), + f"Downloading {self.model}", + eager_start=False, ) if self.download_task.done(): diff --git a/homeassistant/components/zeroconf/__init__.py b/homeassistant/components/zeroconf/__init__.py index 66c41c19474..5ebe1bb769e 100644 --- a/homeassistant/components/zeroconf/__init__.py +++ b/homeassistant/components/zeroconf/__init__.py @@ -432,6 +432,7 @@ class ZeroconfDiscovery: zeroconf, async_service_info, service_type, name ), name=f"zeroconf lookup {name}.{service_type}", + eager_start=False, ) async def _async_lookup_and_process_service_update( diff --git a/homeassistant/core.py b/homeassistant/core.py index 7e09363178d..aa3b5c8434f 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -742,7 +742,7 @@ class HomeAssistant: @callback def async_create_background_task( - self, target: Coroutine[Any, Any, _R], name: str, eager_start: bool = False + self, target: Coroutine[Any, Any, _R], name: str, eager_start: bool = True ) -> asyncio.Task[_R]: """Create a task from within the event loop.