def restore_state(self, state):
        """Restore the current state of this emulated device.

        Note that restore_state happens synchronously in the emulation thread
        to avoid any race conditions with accessing data members and ensure a
        consistent atomic restoration process.

        This method will block while the background restore happens.

        Args:
            state (dict): A previously dumped state produced by dump_state.
        """

        state_name = state.get('state_name')
        state_version = state.get('state_version')

        if state_name != self.STATE_NAME or state_version != self.STATE_VERSION:
            raise ArgumentError("Invalid emulated device state name or version", found=(state_name, state_version),
                                expected=(self.STATE_NAME, self.STATE_VERSION))

        def _background_restore():
            # Restore the state of all of the tiles
            super(ReferenceDevice, self).restore_state(state)

            self.reset_count = state.get('reset_count', 0)
            self.script = base64.b64decode(state.get('received_script'))

        self.synchronize_task(_background_restore)
def restore_state ( self , state ) : state_name = state . get ( 'state_name' ) state_version = state . get ( 'state_version' ) if state_name != self . STATE_NAME or state_version != self . STATE_VERSION : raise ArgumentError ( "Invalid emulated device state name or version" , found = ( state_name , state_version ) , expected = ( self . STATE_NAME , self . STATE_VERSION ) ) def _background_restore ( ) : super ( ReferenceDevice , self ) . restore_state ( state ) self . reset_count = state . get ( 'reset_count' , 0 ) self . script = base64 . b64decode ( state . get ( 'received_script' ) ) self . synchronize_task ( _background_restore )
Restore the current state of this emulated device.

        Note that restore_state happens synchronously in the emulation thread
        to avoid any race conditions with accessing data members and ensure a
        consistent atomic restoration process.

        This method will block while the background restore happens.

        Args:
            state (dict): A previously dumped state produced by dump_state.