(self)
Resets the variable table for the runspace to the default state.

        This is only supported for the protocol version 2.3 and above (Server
        2016/Windows 10+)
Resets the variable table for the runspace to the default state.
Resets the variable table for the runspace to the default state .
def reset_runspace_state(self):
        """
        Resets the variable table for the runspace to the default state.

        This is only supported for the protocol version 2.3 and above (Server
        2016/Windows 10+)
        """
        log.info("Resetting remote Runspace Pool state")
        if self.state == RunspacePoolState.BEFORE_OPEN:
            # no need to reset if the runspace has not been opened
            return
        elif self.state != RunspacePoolState.OPENED:
            raise InvalidRunspacePoolStateError(
                self.state,
                [RunspacePoolState.BEFORE_OPEN, RunspacePoolState.OPENED],
                "reset RunspacePool state"
            )
        elif not version_equal_or_newer(self.protocol_version, "2.3"):
            raise InvalidPSRPOperation("Cannot reset runspace state on "
                                       "protocol versions older than 2.3, "
                                       "actual: %s" % self.protocol_version)

        def response_handler(response):
            if not response:
                raise InvalidPSRPOperation("Failed to reset runspace state")
            return response

        ci = self._ci_counter
        self._ci_counter += 1
        self.ci_table[ci] = response_handler

        reset_state = ResetRunspaceState(ci=ci)
        data = self._fragmenter.fragment(reset_state, self.id)[0]
        self.shell.send('stdin', data)

        while not isinstance(self.ci_table[ci], bool):
            self._receive()
        del self.ci_table[ci]
def reset_runspace_state ( self ) : log . info ( "Resetting remote Runspace Pool state" ) if self . state == RunspacePoolState . BEFORE_OPEN : # no need to reset if the runspace has not been opened return elif self . state != RunspacePoolState . OPENED : raise InvalidRunspacePoolStateError ( self . state , [ RunspacePoolState . BEFORE_OPEN , RunspacePoolState . OPENED ] , "reset RunspacePool state" ) elif not version_equal_or_newer ( self . protocol_version , "2.3" ) : raise InvalidPSRPOperation ( "Cannot reset runspace state on " "protocol versions older than 2.3, " "actual: %s" % self . protocol_version ) def response_handler ( response ) : if not response : raise InvalidPSRPOperation ( "Failed to reset runspace state" ) return response ci = self . _ci_counter self . _ci_counter += 1 self . ci_table [ ci ] = response_handler reset_state = ResetRunspaceState ( ci = ci ) data = self . _fragmenter . fragment ( reset_state , self . id ) [ 0 ] self . shell . send ( 'stdin' , data ) while not isinstance ( self . ci_table [ ci ] , bool ) : self . _receive ( ) del self . ci_table [ ci ]