Don't send the "can connect" service check if we have troubles getting
        the health status
321832
def _get_health_status(self, url, ssl_params, timeout):
        
        try:
            r = self._perform_request(url, "/health", ssl_params, timeout)
            # we don't use get() here so we can report a KeyError
            return r.json()[self.HEALTH_KEY]
        except Exception as e:
            self.log.debug("Can't determine health status: {}".format(e))
32447
def _finish_connection_action(self, action):
        

        success = action.data['success']
        conn_key = action.data['id']

        if self._get_connection_state(conn_key) != self.Connecting:
            print("Invalid finish_connection action on a connection whose state is not Connecting, conn_key=%s" % str(conn_key))
            return

        # Cannot be None since we checked above to make sure it exists
        data = self._get_connection(conn_key)
        callback = data['callback']

        conn_id = data['conn_id']
        int_id = data['int_id']

        if success is False:
            reason = action.data['reason']
            if reason is None:
                reason = "No reason was given"

            del self._connections[conn_id]
            del self._int_connections[int_id]
            callback(conn_id, self.id, False, reason)
        else:
            data['state'] = self.Idle
            data['microstate'] = None
            data['callback'] = None
            callback(conn_id, self.id, True, None)
621423
@Bean
    public HealthChecker tomcatConnectorHealthChecker(ServletWebServerApplicationContext applicationContext) {
        final Connector connector = getConnector(applicationContext);
        return () -> connector.getState().isAvailable();
    }
868522
public function health()
    {
        try {
            // Logic for validating health (e.g. connections to external
            // services) should go here.

            // If a cache driver is defined, check it is working.
            if (!empty(env('CACHE_DRIVER', null))) {
                Cache::put('health_check', 'test', 1);
                Cache::get('health_check');
            }

            // If a DB connection is defined, check it is working.
            if (!empty(env('DB_HOST', null))) {
                DB::connection()->getPdo();
            }

            // All of our service dependencies are working so build a valid
            // response object.
            return $this->generateResponse('health', null);
        } catch (\Exception $e) {
            return $this->generateResponse('', null, 500, Status::FAIL, $e->getMessage());
        }
    }
5869
def _maybe_reconnect(self):
    """"""
    with self._lock:
      if not self._connected: 
        _LOGGER.info("Connecting")
        self._do_login_locked()
        self._connected = True
        self._connect_cond.notify_all()
        _LOGGER.info("Connected")
188493
def health_check(self):
        """"""
        logger.debug('Health Check on S3 file for: {namespace}'.format(
            namespace=self.namespace
        ))

        try:
            self.client.head_object(Bucket=self.bucket_name, Key=self.data_file)
            return True
        except ClientError as e:
            logger.debug('Error encountered with S3.  Assume unhealthy')
757936
def a_unable_to_connect(ctx):
    
    message = "{}{}".format(ctx.ctrl.before, ctx.ctrl.after)
    ctx.msg = message.strip().splitlines()[-1]
    ctx.device.last_error_msg = ctx.msg
    # ctx.msg = "{}{}".format(ctx.ctrl.before, ctx.ctrl.after)
    return False
1018886
def _check_connection(self):
        """"""
        try:
            super()._check_connection()
        except OSError as exc:
            _LOGGER.error(exc)
            self.protocol.transport.close()
            self.protocol.conn_lost_callback()
            return
        task = self.loop.call_later(
            self.reconnect_timeout + 0.1, self._check_connection)
        self.cancel_check_conn = task.cancel
413940
protected void checkHealth(long threshold, NodeHealthChecker healthChecker) {
        final int state = this.state;
        if (anyAreSet(state, REMOVED | ACTIVE_PING)) {
            return;
        }
        healthCheckPing(threshold, healthChecker);
    }
380229
public function checkConnection()
    {
        try {
            $this->runQuery('', [], true);
        } catch (\Exception $e) {
            if ($e->hasResponse()) {
                switch ($e->getResponse()->getStatusCode()) {
                    case 403:
                        return [
                            'status' => 0,
                            'error' => 'auth_error',
                            'verbose' => 'Check Username and Password/Access Key.'
                        ];
                    default:
                        return [
                            'status' => 0,
                            'error' => 'unknown',
                            'verbose' => 'An unknown error has occurred. Server replied with: ' . $e->getResponse()->getStatusCode()
                        ];
                }
            } else {
                return [
                    'status' => 0,
                    'error' => 'conn_error',
                    'verbose' => 'Check CSF or hostname/port.'
                ];
            }
            return false;
        }

        return [
            'status' => 1,
            'error' => false,
            'verbose' => 'Everything is working.'
        ];
    }
1345335
function (err, pStatus) {
        if (err) {
          log.error(that._name + " - Could not get player status- " + err);
        } else {
          that._playerStatus(pStatus);
        }
      }
884401
def _check_device_failover_status(self, device, status):
        '''
        '''

        sync_status = device.tm.cm.sync_status
        sync_status.refresh()
        current_status = (sync_status.entries[self.sync_status_entry]
                          ['nestedStats']['entries']['status']
                          ['description'])
        if status == current_status:
            return True
        return False
892496
def update_connected(self, status):
        """"""
        self._client['connected'] = status
        _LOGGER.info('updated connected status to %s on %s', status, self.friendly_name)
        self.callback()
71630
def status(self):
        """"""
        try:
            # -- Check client
            res = self.run(['info'])
            if res[0]['clientName'] == '*unknown*':
                return ConnectionStatus.INVALID_CLIENT
            # -- Trigger an auth error if not logged in
            self.run(['user', '-o'])
        except errors.CommandError as err:
            if 'password (P4PASSWD) invalid or unset' in str(err.args[0]):
                return ConnectionStatus.NO_AUTH
            if 'Connect to server failed' in str(err.args[0]):
                return ConnectionStatus.OFFLINE

        return ConnectionStatus.OK
1006595
void doNotifyIfNecessary() {
        if (status.compareAndSet(ConnectionStatus.RUNNING, ConnectionStatus.RELEASE) || status.compareAndSet(ConnectionStatus.TERMINATED, ConnectionStatus.RELEASE)) {
            resourceSynchronizer.doNotify();
        }
    }
288671
def _disconnect_locked(self):
    """"""
    self._connected = False
    self._connect_cond.notify_all()
    self._telnet = None
    _LOGGER.warning("Disconnected")
643227
private RealConnection findHealthyConnection(int connectTimeout, int readTimeout,
      int writeTimeout, int pingIntervalMillis, boolean connectionRetryEnabled,
      boolean doExtensiveHealthChecks) throws IOException {
    while (true) {
      RealConnection candidate = findConnection(connectTimeout, readTimeout, writeTimeout,
          pingIntervalMillis, connectionRetryEnabled);

      // If this is a brand new connection, we can skip the extensive health checks.
      synchronized (connectionPool) {
        if (candidate.successCount == 0) {
          return candidate;
        }
      }

      // Do a (potentially slow) check to confirm that the pooled connection is still good. If it
      // isn't, take it out of the pool and start again.
      if (!candidate.isHealthy(doExtensiveHealthChecks)) {
        candidate.noNewExchanges();
        continue;
      }

      return candidate;
    }
  }