Skip to content

Improper cleanup if there are dependencies #2508

@petersohn

Description

@petersohn

What happened?

To reproduce the issue:

  1. Create two apps, e.g. foo and bar. Make foo a dependency of bar.
  2. Remove bar from the config.
  3. Stop AppDaemon.

After this, weird things happen. bar, which is already terminated, is terminated again, then both foo and bar are restarted.

Version

4.5.12

Installation type

Python virtual environment

Relevant log output

2025-12-16 17:29:12.154295 INFO AppDaemon: Starting apps: ['foo', 'bar']
2025-12-16 17:29:12.155368 INFO AppDaemon: Calling initialize() for foo
2025-12-16 17:29:12.177923 INFO foo: init
2025-12-16 17:29:12.178408 INFO AppDaemon: Calling initialize() for bar
2025-12-16 17:29:12.178906 INFO bar: init
2025-12-16 17:29:17.242288 INFO AppDaemon: App config deleted: bar
2025-12-16 17:29:17.251798 INFO AppDaemon: Stopping apps: ['bar']
2025-12-16 17:29:17.251869 INFO AppDaemon: Calling terminate() for 'bar'
2025-12-16 17:29:17.252336 INFO bar: terminate
2025-12-16 17:29:17.252717 INFO AppDaemon: Stopped app 'bar'
2025-12-16 17:29:24.019481 INFO AppDaemon: Received signal: SIGINT
2025-12-16 17:29:24.019607 INFO AppDaemon: Stopping AppDaemon
2025-12-16 17:29:24.029682 INFO AppDaemon: Stopping apps: ['bar', 'foo']
2025-12-16 17:29:24.029748 INFO AppDaemon: Calling terminate() for 'bar'
2025-12-16 17:29:24.030178 INFO bar: terminate
2025-12-16 17:29:24.030546 INFO AppDaemon: Stopped app 'bar'
2025-12-16 17:29:24.030605 INFO AppDaemon: Calling terminate() for 'foo'
2025-12-16 17:29:24.031010 INFO foo: terminate
2025-12-16 17:29:24.031317 INFO AppDaemon: Stopped app 'foo'
2025-12-16 17:29:24.031414 INFO AppDaemon: Starting apps: ['foo', 'bar']
2025-12-16 17:29:24.032311 INFO AppDaemon: Calling initialize() for foo
2025-12-16 17:29:24.032738 INFO foo: init
2025-12-16 17:29:24.033028 INFO AppDaemon: Calling initialize() for bar
2025-12-16 17:29:24.033438 INFO bar: init
2025-12-16 17:29:24.033910 INFO AppDaemon: All plugins stopped gracefully
2025-12-16 17:29:24.034257 INFO AppDaemon: Scheduler finished gracefully
2025-12-16 17:29:24.034394 INFO AppDaemon: Stopped HTTP server gracefully
2025-12-16 17:29:24.034451 INFO AppDaemon: AppDaemon is stopped.
2025-12-16 17:29:24.034507 INFO AppDaemon: AppDaemon main() stopped gracefully in 14.937ms

Relevant code in the app or config file that caused the issue

foo.py

class Foo(appdaemon.plugins.hass.hassapi.Hass):
    def initialize(self):
        self.log("init")

    def terminate(self):
        self.log("terminate")

apps.yaml

foo:
  module: foo
  class: Foo

bar:
  module: foo
  class: Foo
  dependencies: foo

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    issueSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions