Fix deprecated asyncio.wait use with coroutines (#44981)
https://docs.python.org/3/library/asyncio-task.html#asyncio-example-wait-coroutinepull/46329/head
parent
4b493c5ab9
commit
a6358430b4
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
]
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
]
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
]
|
||||
|
||||
|
|
|
@ -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)
|
||||
]
|
||||
|
||||
|
|
|
@ -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)
|
||||
]
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue