From a6358430b46a68b6aee74dd223da29511ecb9bc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Wed, 10 Feb 2021 15:16:58 +0200 Subject: [PATCH] Fix deprecated asyncio.wait use with coroutines (#44981) https://docs.python.org/3/library/asyncio-task.html#asyncio-example-wait-coroutine --- homeassistant/components/config/__init__.py | 4 ++-- homeassistant/components/device_tracker/legacy.py | 2 +- homeassistant/components/forked_daapd/media_player.py | 2 +- homeassistant/components/image_processing/__init__.py | 2 +- homeassistant/components/mailbox/__init__.py | 2 +- homeassistant/components/microsoft_face/__init__.py | 4 +++- homeassistant/components/notify/__init__.py | 2 +- homeassistant/components/stt/__init__.py | 2 +- homeassistant/components/tts/__init__.py | 2 +- homeassistant/helpers/script.py | 2 +- homeassistant/helpers/service.py | 6 ++++-- 11 files changed, 17 insertions(+), 13 deletions(-) diff --git a/homeassistant/components/config/__init__.py b/homeassistant/components/config/__init__.py index 1098594a04c..7d07710a4d0 100644 --- a/homeassistant/components/config/__init__.py +++ b/homeassistant/components/config/__init__.py @@ -65,11 +65,11 @@ async def async_setup(hass, config): hass.bus.async_listen(EVENT_COMPONENT_LOADED, component_loaded) - tasks = [setup_panel(panel_name) for panel_name in SECTIONS] + tasks = [asyncio.create_task(setup_panel(panel_name)) for panel_name in SECTIONS] for panel_name in ON_DEMAND: if panel_name in hass.config.components: - tasks.append(setup_panel(panel_name)) + tasks.append(asyncio.create_task(setup_panel(panel_name))) if tasks: await asyncio.wait(tasks) diff --git a/homeassistant/components/device_tracker/legacy.py b/homeassistant/components/device_tracker/legacy.py index 5f60d84f406..b7583d80f82 100644 --- a/homeassistant/components/device_tracker/legacy.py +++ b/homeassistant/components/device_tracker/legacy.py @@ -153,7 +153,7 @@ async def async_setup_integration(hass: HomeAssistantType, config: ConfigType) - legacy_platforms = await async_extract_config(hass, config) setup_tasks = [ - legacy_platform.async_setup_legacy(hass, tracker) + asyncio.create_task(legacy_platform.async_setup_legacy(hass, tracker)) for legacy_platform in legacy_platforms ] diff --git a/homeassistant/components/forked_daapd/media_player.py b/homeassistant/components/forked_daapd/media_player.py index 195ebf7e2cf..724db80fabd 100644 --- a/homeassistant/components/forked_daapd/media_player.py +++ b/homeassistant/components/forked_daapd/media_player.py @@ -855,7 +855,7 @@ class ForkedDaapdUpdater: ) if update_events: await asyncio.wait( - [event.wait() for event in update_events.values()] + [asyncio.create_task(event.wait()) for event in update_events.values()] ) # make sure callbacks done before update async_dispatcher_send( self.hass, SIGNAL_UPDATE_MASTER.format(self._entry_id), True diff --git a/homeassistant/components/image_processing/__init__.py b/homeassistant/components/image_processing/__init__.py index 261278da401..e885a9ca7a9 100644 --- a/homeassistant/components/image_processing/__init__.py +++ b/homeassistant/components/image_processing/__init__.py @@ -81,7 +81,7 @@ async def async_setup(hass, config): update_tasks = [] for entity in image_entities: entity.async_set_context(service.context) - update_tasks.append(entity.async_update_ha_state(True)) + update_tasks.append(asyncio.create_task(entity.async_update_ha_state(True))) if update_tasks: await asyncio.wait(update_tasks) diff --git a/homeassistant/components/mailbox/__init__.py b/homeassistant/components/mailbox/__init__.py index e5a0f16863d..5d05596fb23 100644 --- a/homeassistant/components/mailbox/__init__.py +++ b/homeassistant/components/mailbox/__init__.py @@ -84,7 +84,7 @@ async def async_setup(hass, config): await component.async_add_entities([mailbox_entity]) setup_tasks = [ - async_setup_platform(p_type, p_config) + asyncio.create_task(async_setup_platform(p_type, p_config)) for p_type, p_config in config_per_platform(config, DOMAIN) ] diff --git a/homeassistant/components/microsoft_face/__init__.py b/homeassistant/components/microsoft_face/__init__.py index 69a738724c3..b9046429603 100644 --- a/homeassistant/components/microsoft_face/__init__.py +++ b/homeassistant/components/microsoft_face/__init__.py @@ -275,7 +275,9 @@ class MicrosoftFace: for person in persons: self._store[g_id][person["name"]] = person["personId"] - tasks.append(self._entities[g_id].async_update_ha_state()) + tasks.append( + asyncio.create_task(self._entities[g_id].async_update_ha_state()) + ) if tasks: await asyncio.wait(tasks) diff --git a/homeassistant/components/notify/__init__.py b/homeassistant/components/notify/__init__.py index d3439baf4fb..1e9c7d8595a 100644 --- a/homeassistant/components/notify/__init__.py +++ b/homeassistant/components/notify/__init__.py @@ -312,7 +312,7 @@ async def async_setup(hass, config): ) setup_tasks = [ - async_setup_platform(integration_name, p_config) + asyncio.create_task(async_setup_platform(integration_name, p_config)) for integration_name, p_config in config_per_platform(config, DOMAIN) ] diff --git a/homeassistant/components/stt/__init__.py b/homeassistant/components/stt/__init__.py index 43ef01a497e..0ad621f0707 100644 --- a/homeassistant/components/stt/__init__.py +++ b/homeassistant/components/stt/__init__.py @@ -62,7 +62,7 @@ async def async_setup(hass: HomeAssistantType, config): return setup_tasks = [ - async_setup_platform(p_type, p_config) + asyncio.create_task(async_setup_platform(p_type, p_config)) for p_type, p_config in config_per_platform(config, DOMAIN) ] diff --git a/homeassistant/components/tts/__init__.py b/homeassistant/components/tts/__init__.py index d278283baaf..ff1bf946e83 100644 --- a/homeassistant/components/tts/__init__.py +++ b/homeassistant/components/tts/__init__.py @@ -194,7 +194,7 @@ async def async_setup(hass, config): ) setup_tasks = [ - async_setup_platform(p_type, p_config) + asyncio.create_task(async_setup_platform(p_type, p_config)) for p_type, p_config in config_per_platform(config, DOMAIN) ] diff --git a/homeassistant/helpers/script.py b/homeassistant/helpers/script.py index a0e8311048e..3cc8348961f 100644 --- a/homeassistant/helpers/script.py +++ b/homeassistant/helpers/script.py @@ -1055,7 +1055,7 @@ class Script: raise async def _async_stop(self, update_state): - aws = [run.async_stop() for run in self._runs] + aws = [asyncio.create_task(run.async_stop()) for run in self._runs] if not aws: return await asyncio.wait(aws) diff --git a/homeassistant/helpers/service.py b/homeassistant/helpers/service.py index a13b866a418..b2fa97d51cc 100644 --- a/homeassistant/helpers/service.py +++ b/homeassistant/helpers/service.py @@ -602,8 +602,10 @@ async def entity_service_call( done, pending = await asyncio.wait( [ - entity.async_request_call( - _handle_entity_call(hass, entity, func, data, call.context) + asyncio.create_task( + entity.async_request_call( + _handle_entity_call(hass, entity, func, data, call.context) + ) ) for entity in entities ]