def keep_rects_attrs(self, *attr_names):
        """Restore initial size/pos of rects when resuming."""
        ### map rect ids to the values of the attributes
        ### named

        backup = {
            id(rect): tuple(getattr(rect, name) for name in attr_names)
            for rect in self._get_all_rects()
        }

        ### suspend execution by yielding;
        ###
        ### exceptions occurring in this step are
        ### purposefully not caught;
        yield

        ### restore size and position of rects

        for rect in self._get_all_rects():

            for name, value in zip(attr_names, backup[id(rect)]):
                setattr(rect, name, value)
Restore initial size/pos of rects when resuming.
nodezator/rectsman/main.py