Closed mthaddon closed 1 year ago
I should mention that this is happening within an Operator Framework charm, and the code in question is within a function that's called as part of an action event handler. It's possible this isn't how this is intended to be used, would appreciate confirmation either way.
Hi @mthaddon
Yes, some parts of hookenv (the submodule) expects the using-code to be using the Hooks
class which automatically does-the-right-thing by calling _run_atstart()
and _run_atexit()
, and Config
is one of those that expect to work this way. Curiously, the Services framework also uses it, but then I know of only a couple of charms that still use that framework!
charms.reactive
also automatically calls the hookenv
atexit
code handlers in the right places too. I'm guessing for an ops framework charm you'll need to do this manually somewhere in the framework.
I'm going to close this as I don't think it's a bug, but please do re-open it if you get further information. Thanks.
I've been trying to debug a problem in a charm where the charm code does the following:
However, it looks like
cfg.previous("some-key")
is alwaysNone
. From what I can tell this is because in the__init__
method for theConfig
class we haveatexit(self._implicit_save)
. However, because we're not calling_run_atexit()
all this does is append the function to a list that might be called, but never is.