@@ -469,23 +469,23 @@ async def wait_for_plugins(self, timeout: float | None = None):
469469 self .AD .loop .create_task (event .wait (), name = f"waiting for { plugin_name } to be ready" )
470470 for plugin_name , event in self ._ready_events ()
471471 ]
472- readiness = self .AD .loop .create_task (
473- asyncio .wait (wait_tasks , timeout = timeout , return_when = asyncio .ALL_COMPLETED ),
474- name = "waiting for all plugins to be ready" ,
475- )
472+ if wait_tasks :
473+ readiness = self .AD .loop .create_task (
474+ asyncio .wait (wait_tasks , timeout = timeout , return_when = asyncio .ALL_COMPLETED ),
475+ name = "waiting for all plugins to be ready" ,
476+ )
476477
477- early_stop = self .AD .loop .create_task (self .AD .stop_event .wait (), name = "waiting for appdaemon to stop" )
478- await self .AD .loop .create_task (
479- asyncio .wait ((readiness , early_stop ), timeout = timeout , return_when = asyncio .FIRST_COMPLETED ),
480- name = "waiting for plugins or stop event" ,
481- )
482- if readiness .done ():
483- # The readiness wait completed
484- self .logger .info ("All plugins ready" )
485- elif self .AD .stopping :
486- self .logger .info ("AppDaemon stopping before all plugins ready, cancelling readiness waits" )
487- for task in wait_tasks :
488- task .cancel ()
478+ early_stop = self .AD .loop .create_task (self .AD .stop_event .wait (), name = "waiting for appdaemon to stop" )
479+ await self .AD .loop .create_task (
480+ asyncio .wait ((readiness , early_stop ), timeout = timeout , return_when = asyncio .FIRST_COMPLETED ),
481+ name = "waiting for plugins or stop event" ,
482+ )
483+ if self .AD .stopping :
484+ self .logger .info ("AppDaemon stopping before all plugins ready, cancelling readiness waits" )
485+ for task in wait_tasks :
486+ task .cancel ()
487+ return
488+ self .logger .info ("All plugins ready" )
489489
490490 def get_config_for_namespace (self , namespace : str ) -> PluginConfig :
491491 plugin_name = self .get_plugin_from_namespace (namespace )
0 commit comments