ros / executive_smach

A procedural python-based task execution framework with ROS integration.
Other
173 stars 141 forks source link

State machines cannot be pickled #85

Open InigoMoreno opened 3 years ago

InigoMoreno commented 3 years ago

I was trying to pickle a State machine in order to save it on a file to be executed later and I saw that it cannot be pickled due to the _state_transitioning_lock variable. This could be fixed by adding the following to the state_machine class:

    def __getstate__(self):
        return {k:v for (k, v) in self.__dict__.items() if k is not "_state_transitioning_lock"}

    def __setstate__(self, d):
        self.__dict__ = d
        self._state_transitioning_lock = threading.Lock()