mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Add support for eager tasks (#111425)
* Add support for eager tasks python 3.12 supports eager tasks reading: https://docs.python.org/3/library/asyncio-task.html#eager-task-factory https://github.com/python/cpython/issues/97696 There are lots of places were we are unlikely to suspend, but we might suspend so creating a task makes sense * reduce * revert entity * revert * coverage * coverage * coverage * coverage * fix test
This commit is contained in:
@@ -260,14 +260,14 @@ async def async_test_home_assistant(
|
||||
|
||||
return orig_async_add_executor_job(target, *args)
|
||||
|
||||
def async_create_task(coroutine, name=None):
|
||||
def async_create_task(coroutine, name=None, eager_start=False):
|
||||
"""Create task."""
|
||||
if isinstance(coroutine, Mock) and not isinstance(coroutine, AsyncMock):
|
||||
fut = asyncio.Future()
|
||||
fut.set_result(None)
|
||||
return fut
|
||||
|
||||
return orig_async_create_task(coroutine, name)
|
||||
return orig_async_create_task(coroutine, name, eager_start)
|
||||
|
||||
hass.async_add_job = async_add_job
|
||||
hass.async_add_executor_job = async_add_executor_job
|
||||
|
||||
Reference in New Issue
Block a user