Return the active ClientState instance.
546726
def get_client_state(self):
        "  "
        app = get_app()
        for client_state in self._client_states.values():
            if client_state.app == app:
                return client_state

        raise ValueError('Client state for app %r not found' % (app, ))
752738
public function activeState()
    {
        if (!empty($this->state) && $this->state->isActive()) {
            return $this->getState();
        }

        if (!empty($this->defaultState) && $this->defaultState->isActive()) {
            //Falling back to default state
            return $this->getDefaultState();
        }

        if (empty($this->defaultState) && !empty($this->state)) {
            //No default state, so we have to use state anyway
            return $this->getState();
        }

        throw new ListingException("Unable to get active state, no active states are set");
    }
1096392
def state(self):
        """"""
        if self._proto.HasField('state'):
            return yamcsManagement_pb2.ServiceState.Name(self._proto.state)
        return None
383415
@Override
    public Client getClientInstance()
    {
        // if threadsafe recycle the same single instance; if not create a new
        // instance

        if (isThreadSafe())
        {
            logger.info("Returning threadsafe used client instance for persistence unit : " + persistenceUnit);
            if (client == null)
            {
                client = instantiateClient(persistenceUnit);
            }
        }
        else
        {
            logger.debug("Returning fresh client instance for persistence unit : " + persistenceUnit);
            // no need to hold a client reference.
            return instantiateClient(persistenceUnit);
        }

        return client;
    }
581036
def active(self) -> bool:
        """"""
        states = self._client.get_state(self._state_url)['states']
        for state in states:
            state = state['State']
            if int(state['Id']) == self._state_id:
                # yes, the ZM API uses the *string* "1" for this...
                return state['IsActive'] == "1"
        return False
1123916
def get_service_state(self, service_id: str) -> str:
        
        # Get service
        service = self._client.services.get(service_id)

        # Get the state of the service
        for service_task in service.tasks():
            service_state = service_task['DesiredState']
        return service_state
470238
function getLibStateAccessor(libState) {
      /** The current state name */
      return { get actionName() {
          return libState.actionName;
        }
        /** Is in idle state (no more states to progress to) */
        , get isIdle() {
          return libState.isIdle;
        }
        /** State can be paused manually or via action dispatch or returning null/undefined from timeoutMS function */
        , get isPaused() {
          return libState.isPaused;
        }
        /** The epoch MS that the user was last active */
        , get lastActive() {
          return useFastStore ? fastState.lastActive : libState.lastActive;
        }
        /** Event information captured on the last recorded user action */
        , get lastEvent() {
          return useFastStore ? fastState.lastEvent : libState.lastEvent;
        }
        /** The timeoutID for the current scheduled next event if it exists */
        , get timeoutID() {
          return useFastStore ? fastState.timeoutID : libState.timeoutID;
        }
      };
    }
529421
public ClientSocket openIfHeartbeatActive()
  {
    if (_state.isClosed()) {
      return null;
    }
    
    if (! _isHeartbeatActive && _isHeartbeatServer) {
      return null;
    }

    ClientSocket stream = openRecycle();

    if (stream != null)
      return stream;

    return connect();
  }
935114
def client_status(self, config_path):
        """"""
        c = self.client_for(config_path)
        status = "stopped"
        if not c or not c.ensime:
            status = 'unloaded'
        elif c.ensime.is_ready():
            status = 'ready'
        elif c.ensime.is_running():
            status = 'startup'
        elif c.ensime.aborted():
            status = 'aborted'
        return status
1034062
def client(self):
        
        if self._client is None:
            self._client = client.get_client()

        return self._client
495158
def active(self):
        

        context = self._get_context()
        if not context:
            return super(TornadoScopeManager, self).active

        return context.active
717054
function ClientState(client) {

  /**
   * The associated client instance.
   *
   * @property client
   * @type Client
   */
  this.client = client;

  /**
   * The time (in milliseconds) to wait before the next request
   * may be sent to the API; this value is only updated upon
   * reception of a server response and thus valid only in
   * combination with the time of reception.
   *
   * @property retry
   * @type Number
   */
  this.retry = 0;

  /**
   * The time (in milliseconds) the client should back-off
   * before resuming normal API interactions; this value is
   * only updated upon reception of a server response and
   * thus valid only in combination with the time of reception.
   *
   * @property backoff
   * @type Number
   */
  this.backoff = 0;

  /**
   * The HTTP status code of the last response received
   * by the client.
   *
   * @property code
   * @type Number|null
   */
  this.code = null;

  /**
   * The UNIX timestamp of the last API response received
   * by the client.
   *
   * @property timestamp
   * @type Number
   */
  this.timestamp = Date.now();
}
882882
protected final SessionState getSessionState() {
        if (sessionTracker != null) {
            Session currentSession = sessionTracker.getSession();
            return (currentSession != null) ? currentSession.getState() : null;
        }
        return null;
    }
1371071
async def get_status(self, filters=None, utc=False):
        
        client_facade = client.ClientFacade.from_connection(self.connection())
        return await client_facade.FullStatus(filters)
415172
def state(self) -> str:
        """"""
        return self._coerce_state_from_string(
            next(
                attr['Value'] for attr in self._device_json.get(
                    'Attributes', [])
                if attr.get('AttributeDisplayName') == 'doorstate'))
814244
def GetClientStates(self, client_list, client_chunk=50):
    """"""
    for client_group in collection.Batch(client_list, client_chunk):
      for fd in aff4.FACTORY.MultiOpen(
          client_group,
          mode="r",
          aff4_type=aff4_grr.VFSGRRClient,
          token=self.token):
        result = {}
        result["age"] = fd.Get(fd.Schema.PING)
        result["hostname"] = fd.Get(fd.Schema.HOSTNAME)
        yield (fd.urn, result)
1358553
def use(self, client_key):
        
        if not self.clients.has_client(client_key):
            raise ClientNotExist()

        self.current_client = self.clients.get_client(client_key)

        return self