Skip to content

Fix #1949 process on_stop call sequence for macros without checkpoint

Following on what has been discussed in #1949 (closed)

This specific case was with the mv macro, but applies to any macro that does not contain checkpoints (mAPI). In that cases the current macro is stopped but the propagation is not handled properly as the StopException is not being raised (since it is done in the mAPI decorator).

Now, after adding the macro_obj.checkPoint call in MacroExecutor.runMacro and running the following test macro as described in the issue:

class test_regression_create_macro_mvr(Macro):
    """
    The main macro on_stop is not called but only when the loop is
finished.
    This is a regression.
    """
    def run(self):
        m, _ = self.createMacro("mvr", [["dmot01", 100]])
        for i in range(10):
            self.info(f"Point: {i}")
            self.runMacro(m)
            self.checkPoint()
    
    def on_stop(self):
        self.info("parent macro on_stop called")

The abort is stopping the macro loop and the on_stop of the parent is called

Door_macroserver_1 (READY) [102]: %test_regression_create_macro_mvr
Point: 0
Point: 1
^C
Ctrl-C received: Stopping...
Stopping Motion(['dmot01']) reserved by mv
Motion(['dmot01']) stopped
Executing mv.on_stop method...
Executing mvr.on_stop method...
Executing test_regression_create_macro_mvr.on_stop method...
parent macro on_stop called
Stopping done!

Door_macroserver_1 (READY) [103]: 

Merge request reports