mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Make eager_start default to True for async_create_task (#114995)
This commit is contained in:
parent
fa47e79292
commit
c33a234048
@ -719,7 +719,7 @@ class HomeAssistant:
|
||||
self,
|
||||
target: Coroutine[Any, Any, _R],
|
||||
name: str | None = None,
|
||||
eager_start: bool = False,
|
||||
eager_start: bool = True,
|
||||
) -> asyncio.Task[_R]:
|
||||
"""Create a task from within the event loop.
|
||||
|
||||
|
@ -327,7 +327,7 @@ async def test_async_create_task_schedule_coroutine() -> None:
|
||||
async def job():
|
||||
pass
|
||||
|
||||
ha.HomeAssistant.async_create_task(hass, job())
|
||||
ha.HomeAssistant.async_create_task(hass, job(), eager_start=False)
|
||||
assert len(hass.loop.call_soon.mock_calls) == 0
|
||||
assert len(hass.loop.create_task.mock_calls) == 1
|
||||
assert len(hass.add_job.mock_calls) == 0
|
||||
@ -353,7 +353,9 @@ async def test_async_create_task_schedule_coroutine_with_name() -> None:
|
||||
async def job():
|
||||
pass
|
||||
|
||||
task = ha.HomeAssistant.async_create_task(hass, job(), "named task")
|
||||
task = ha.HomeAssistant.async_create_task(
|
||||
hass, job(), "named task", eager_start=False
|
||||
)
|
||||
assert len(hass.loop.call_soon.mock_calls) == 0
|
||||
assert len(hass.loop.create_task.mock_calls) == 1
|
||||
assert len(hass.add_job.mock_calls) == 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user