yr.Group.suspend#
- Group.suspend()[source]#
Suspend all instances managed by this Group.
This method terminates all instances created and managed by the Group, while first checkpointing their state and metadata. The checkpoint allows the Group to preserve necessary instance information before the instances are killed and their resources are released.
The saved checkpoint can later be used by resume to recover and restart the instances. .. rubric:: Examples
>>> import yr >>> >>> yr.init() >>> >>> @yr.instance ... class Counter: ... sum = 0 ... ... def add(self, a): ... self.sum += a ... >>> group_opts = yr.GroupOptions() >>> group_name = "test" >>> g = yr.Group(group_name, group_opts) >>> opts = yr.InvokeOptions() >>> opts.group_name = group_name >>> ins = Counter.options(opts).invoke() >>> g.invoke() >>> res = ins.add.invoke() >>> print(yr.get(res)) >>> >>> g.suspend() >>> g.resume() >>> res = ins.add.invoke() >>> print(yr.get(res)) >>> yr.finalize()