Skip to content

Commit 5fca37a

Browse files
committed
Merge branch 'dev' of https://github.com/AppDaemon/appdaemon into dev
2 parents a0219ea + cc61945 commit 5fca37a

File tree

2 files changed

+33
-16
lines changed

2 files changed

+33
-16
lines changed

appdaemon/plugin_management.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

tests/functional/test_startup.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,20 @@ async def test_hello_world(ad: AppDaemon, caplog: pytest.LogCaptureFixture, app_
2323

2424
assert "Hello from AppDaemon" in caplog.text
2525
assert "You are now ready to run Apps!" in caplog.text
26+
27+
28+
@pytest.mark.ci
29+
@pytest.mark.functional
30+
@pytest.mark.asyncio(loop_scope="session")
31+
async def test_no_plugins(ad_obj: AppDaemon, caplog: pytest.LogCaptureFixture) -> None:
32+
"""Ensure that apps start correctly when there are no plugins configured."""
33+
ad_obj.config.plugins = {}
34+
ad_obj.app_dir = ad_obj.config_dir / "apps/hello_world"
35+
36+
ad_obj.start()
37+
with caplog.at_level(logging.INFO, logger="AppDaemon"):
38+
async with ad_obj.app_management.app_run_context("hello_world"):
39+
await ad_obj.utility.app_update_event.wait()
40+
41+
await ad_obj.stop()
42+
assert not any(r.levelname == "ERROR" for r in caplog.records)

0 commit comments

Comments
 (0)