def apply_snapshot(self, entry): old_agent, old_protocols = self.agent, self.protocols self.reset() args, kwargs = replay.replay(entry, entry.get_arguments) self._restore_snapshot(*args, **kwargs) self._check_snapshot(old_agent, old_protocols) self.agent_type = self.agent.descriptor_type
def replay_agency_entry(self, entry): # Special case for snapshot call, because we don't want # to unserialize any arguments before reseting the registry. if entry.function_id == "snapshot": self.apply_snapshot(entry) return self._log_entry(entry) method = getattr(self, "effect_%s" % entry.function_id) args, kwargs = entry.get_arguments() return replay.replay(entry, method, *args, **kwargs)
def apply_snapshot(self, entry): old_agent, old_protocols = self.agent, self.protocols self.reset() self.set_current_time(entry._timestamp) args, _kwargs = replay.replay(entry, entry.get_arguments) if not args: # we can get entry without the arguments in case it was # impossible to serialize the snapshot of the agent raise ReplayError("Malformed agent snapshot, reason: %r" % (entry.result,)) snapshot = args[0] self._restore_snapshot(snapshot) self._check_snapshot(old_agent, old_protocols) self.agent_type = self.agent.descriptor_type