From 7e80dce5d35e93ece18220978073c9f1193fd473 Mon Sep 17 00:00:00 2001 From: Mustafa Kemal Gilor Date: Thu, 23 Jun 2022 16:13:22 +0300 Subject: [PATCH] invoke `hookenv._run_atexit()` when action ends the registered callbacks for `atexit()` were not executing due to `_run_atexit()` is not being called, the `ch_core.hookenv._run_atexit()` function is now explicitly called when action ends. also moved `ch_core.hookenv._run_atstart()` call to `main()` for consistency. Closes-bug: #1976169 Signed-off-by: Mustafa Kemal Gilor Change-Id: I2b976af908dd6ae6248f405fa6980beef0554be5 --- src/actions/actions.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/actions/actions.py b/src/actions/actions.py index 8f5cab3..e212f50 100755 --- a/src/actions/actions.py +++ b/src/actions/actions.py @@ -31,8 +31,6 @@ import charms_openstack.charm as charm # load reactive interfaces reactive.bus.discover() -# load Endpoint based interface data -ch_core.hookenv._run_atstart() # load charm class charms_openstack.bus.discover() @@ -55,6 +53,7 @@ ACTIONS = { def main(args): + ch_core.hookenv._run_atstart() action_name = os.path.basename(args[0]) try: action = ACTIONS[action_name] @@ -71,6 +70,8 @@ def main(args): traceback.format_exc()), level=ch_core.hookenv.ERROR) ch_core.hookenv.action_fail(str(e)) + finally: + ch_core.hookenv._run_atexit() if __name__ == '__main__':