def _new_from_state(self, actor_type, state):
        """Return a restored actor in PENDING state, raises an exception on failure."""
        try:
            _log.analyze(self.node.id, "+", state)
            credentials = state.pop('credentials', None)
            try:
                state['_managed'].remove('credentials')
            except:
                pass
            a = self._new_actor(actor_type, actor_id=state['id'], credentials=credentials)
            if '_shadow_args' in state:
                # We were a shadow, do a full init
                args = state.pop('_shadow_args')
                state['_managed'].remove('_shadow_args')
                a.init(**args)
                # If still shadow don't call did_migrate
                did_migrate = isinstance(a, ShadowActor)
            else:
                did_migrate = True
            # Always do a set_state for the port's state
            a._set_state(state)
            self.node.pm.add_ports_of_actor(a)
            if did_migrate:
                a.did_migrate()
            a.setup_complete()
        except Exception as e:
            _log.exception("Catched new from state %s %s" % (a, dir(a)))
            raise(e)
        return a
dataset/ETHPy150Open EricssonResearch/calvin-base/calvin/runtime/north/actormanager.py/ActorManager._new_from_state/original