160,169c160,161
< # This loops until all objects have been fully drained.
< def doDrain(root):
< all_drained = drain(root)
< while (not all_drained):
< all_drained = drain(root)
<
< # Tries to drain all objects. Draining might not be completed unless
< # all objects return that they are drained on the first call. This is
< # because as objects drain they may cause other objects to no longer
< # be drained.
---
> # Drain the system in preparation of a checkpoint or memory mode
> # switch.
171,181c163,178
< all_drained = False
< dm = internal.drain.createDrainManager()
< unready_objs = sum(obj.drain(dm) for obj in root.descendants())
< # If we've got some objects that can't drain immediately, then simulate
< if unready_objs > 0:
< dm.setCount(unready_objs)
< simulate()
< else:
< all_drained = True
< internal.drain.cleanupDrainManager(dm)
< return all_drained
---
> # Try to drain all objects. Draining might not be completed unless
> # all objects return that they are drained on the first call. This
> # is because as objects drain they may cause other objects to no
> # longer be drained.
> def _drain():
> all_drained = False
> dm = internal.drain.createDrainManager()
> unready_objs = sum(obj.drain(dm) for obj in root.descendants())
> # If we've got some objects that can't drain immediately, then simulate
> if unready_objs > 0:
> dm.setCount(unready_objs)
> simulate()
> else:
> all_drained = True
> internal.drain.cleanupDrainManager(dm)
> return all_drained
182a180,183
> all_drained = _drain()
> while (not all_drained):
> all_drained = _drain()
>
190c191
< doDrain(root)
---
> drain(root)
200c201
< doDrain(system)
---
> drain(system)