From 9f4874bb81c615c90edf0312b4b862052518c5a2 Mon Sep 17 00:00:00 2001 From: Anders Melchiorsen Date: Sat, 20 Feb 2021 19:57:46 +0100 Subject: [PATCH] Explicitly create_task for asyncio.wait (#46325) --- homeassistant/components/script/__init__.py | 5 ++++- homeassistant/helpers/service.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/script/__init__.py b/homeassistant/components/script/__init__.py index eab30e01ee2..5de3cb8264f 100644 --- a/homeassistant/components/script/__init__.py +++ b/homeassistant/components/script/__init__.py @@ -181,7 +181,10 @@ async def async_setup(hass, config): return await asyncio.wait( - [script_entity.async_turn_off() for script_entity in script_entities] + [ + asyncio.create_task(script_entity.async_turn_off()) + for script_entity in script_entities + ] ) async def toggle_service(service): diff --git a/homeassistant/helpers/service.py b/homeassistant/helpers/service.py index d4eacbc0503..01fb76ec1bc 100644 --- a/homeassistant/helpers/service.py +++ b/homeassistant/helpers/service.py @@ -629,7 +629,7 @@ async def entity_service_call( # Context expires if the turn on commands took a long time. # Set context again so it's there when we update entity.async_set_context(call.context) - tasks.append(entity.async_update_ha_state(True)) + tasks.append(asyncio.create_task(entity.async_update_ha_state(True))) if tasks: done, pending = await asyncio.wait(tasks)