<div dir="ltr"><div>Hi,</div><div><br></div><div>It seems the reactive framework is flushing the states at the end of hook execution. This may surprise charm authors. Consider the following code:</div><div><br></div><div>@when_not("initialized")</div><div>def <span class="" id=":1t0.2" tabindex="-1" style="">init</span>():</div><div>    must_be_called_exactly_once()<br></div><div>    set_state("initialized")<br></div><div><br></div><div>@when("initialized")</div><div><div>@when_not("ready")</div></div><div>def get_ready():<br></div><div>    this_call_fails()</div><div>    set_state("ready")</div><div><br></div><div>As a charm author I would expect the "initialized" state set right after the must_be_called_exactly_once() is called. However, the framework is not persisting the "initialized" state at that point, and it moves on to trigger the get_ready(). Since this_call_fails() happens on the  get_ready() method I would expect the "initialized" state to be set when the failure is resolved.</div><div><br></div><div>The reason why the states are not set right away is that the entire hook is tried after resolving the error. However, since hooks are hidden from the charm author it is not clear when a hook starts and when it finishes. Also, the set_state's behaviour of not immediately setting the state is counter-intuitive.</div><div><br></div><div>Thanks,</div><div><span class="" id=":1t0.8" tabindex="-1" style="">Konstantinos</span> <span class="" id=":1t0.9" tabindex="-1" style="">Tsakalozos</span></div></div>