Handle a succesful incoming check.
544607
def check_incoming(self, message, addr, protocol):
        
        component = protocol.local_candidate.component

        # find remote candidate
        remote_candidate = None
        for c in self._remote_candidates:
            if c.host == addr[0] and c.port == addr[1]:
                remote_candidate = c
                assert remote_candidate.component == component
                break
        if remote_candidate is None:
            # 7.2.1.3. Learning Peer Reflexive Candidates
            remote_candidate = Candidate(
                foundation=random_string(10),
                component=component,
                transport='udp',
                priority=message.attributes['PRIORITY'],
                host=addr[0],
                port=addr[1],
                type='prflx')
            self._remote_candidates.append(remote_candidate)
            self.__log_info('Discovered peer reflexive candidate %s', remote_candidate)

        # find pair
        pair = self._find_pair(protocol, remote_candidate)
        if pair is None:
            pair = CandidatePair(protocol, remote_candidate)
            pair.state = CandidatePair.State.WAITING
            self._check_list.append(pair)
            self.sort_check_list()

        # triggered check
        if pair.state in [CandidatePair.State.WAITING, CandidatePair.State.FAILED]:
            pair.handle = asyncio.ensure_future(self.check_start(pair))

        # 7.2.1.5. Updating the Nominated Flag
        if 'USE-CANDIDATE' in message.attributes and not self.ice_controlling:
            pair.remote_nominated = True

            if pair.state == CandidatePair.State.SUCCEEDED:
                pair.nominated = True
                self.check_complete(pair)
869496
def handle_status(self):
        """"""
        status = self.get_status()

        if status:
            # Update main-zone
            self.zones['main'].update_status(status)
724105
private function monitorPending()
    {
        foreach ($this->inProcess as $index => $process) {

            /** @var Process $process */
            if ($process->isTerminated()) {

                if ($process->isSuccessful()) {

                    call_user_func($this->onSuccess, $process->getOutput(), $index);

                } else {

                    call_user_func($this->onError, $process->getErrorOutput(), $index);
                }

                unset($this->inProcess[$index]);

                $this->addPending();
            }
        }
    }
1072505
private void processCheckpoint(Tuple input) {
        Action action = (Action) input.getValueByField(CheckpointSpout.CHECKPOINT_FIELD_ACTION);
        long txid = input.getLongByField(CheckpointSpout.CHECKPOINT_FIELD_TXID);
        if (shouldProcessTransaction(action, txid)) {
            LOG.debug("Processing action {}, txid {}", action, txid);
            try {
                if (txid >= lastTxid) {
                    handleCheckpoint(input, action, txid);
                    if (action == CheckPointState.Action.ROLLBACK) {
                        lastTxid = txid - 1;
                    } else {
                        lastTxid = txid;
                    }
                } else {
                    LOG.debug("Ignoring old transaction. Action {}, txid {}", action, txid);
                    collector.ack(input);
                }
            } catch (Throwable th) {
                LOG.error("Got error while processing checkpoint tuple", th);
                collector.fail(input);
                collector.reportError(th);
            }
        } else {
            LOG.debug("Waiting for action {}, txid {} from all input tasks. checkPointInputTaskCount {}, " +
                    "transactionRequestCount {}", action, txid, checkPointInputTaskCount, transactionRequestCount);
            collector.ack(input);
        }
    }
919199
def should_execute(self):
        """"""
        return self.args.apply and (self.args.no_confirm or self.confirm_execution())
792695
def handle(self, *args, **options):
        """"""
        if options['clean']:
            clean()

        if options['local']:
            local()

        if options['remote']:
            results = remote()
            render = lambda t: render_to_string(t, results)
            if options['notify']:
                send_mail(
                    options['subject'],
                    render('summary.txt'),
                    options['from'],
                    [options['notify']],
                    html_message=render('summary.html'),
                    fail_silently=False,
                )
1190767
function check() {
        if (done) {
          return;
        }
        checks--;
        if (checks <= 0) {
          return;
        }
        if (checks === 0) {
          done = true;
          finish(new Error('Machine unresponsive to STOP'));
          return;
        }
        var checkOptions = {
          method: 'GET',
          path: self.account + '/machines/' + serverId
        };

        self._request(checkOptions, function (err, body) {
          if (err) { return callback && callback(err) }
          if (body && body.state === 'stopped') {
            done = true;
            finish();
            return;
          }
        });

        setTimeout(check, 5000);
      }
983523
def RegisterCheck(cls, check, source="unknown", overwrite_if_exists=False):
    """"""
    if not overwrite_if_exists and check.check_id in cls.checks:
      raise DefinitionError(
          "Check named %s already exists and "
          "overwrite_if_exists is set to False." % check.check_id)
    check.loaded_from = source
    cls.checks[check.check_id] = check
    cls.triggers.Update(check.triggers, check)
555081
public function periodicallyCheck()
    {
        if (!$this->isEnabled()) {
            return;
        }

        $data = $this->cache->fetch('version_check');
        if (!is_array($data)) {
            $this->check();
        }
    }
358633
public function forceCheckIn()
    {
        $db = Database::connection();
        $q = 'update Pages set cIsCheckedOut = 0, cCheckedOutUID = null, cCheckedOutDatetime = null, cCheckedOutDatetimeLastEdit = null where cID = ?';
        $db->executeQuery($q, [$this->cID]);
    }
543658
def on_post(self, req, resp, **kwargs):
        """"""
        validated = self.require_validated(req)

        return super().on_post(
            req, resp,
            handler=partial(self._create, validated=validated),
            **kwargs
        )
1108184
def handle_input(self, event):
        """"""
        self.update_timeval()
        self.events = []
        code = self._get_event_key_code(event)

        if code in self.codes:
            new_code = self.codes[code]
        else:
            new_code = 0
        event_type = self._get_event_type(event)
        value = self._get_key_value(event, event_type)
        scan_event, key_event = self.emulate_press(
            new_code, code, value, self.timeval)

        self.events.append(scan_event)
        self.events.append(key_event)
        # End with a sync marker
        self.events.append(self.sync_marker(self.timeval))
        # We are done
        self.write_to_pipe(self.events)
668159
def handle?(req)
      if @opts.key?(:if)
        cond = @opts[:if]
        cond = cond.call(req) if cond.respond_to?(:call)
        return cond
      end
      true
    end
934498
public function handleChecks()
    {
        $errors = [];
        foreach ($this->_config['checks'] as $name => $check) {
            if (empty($check)) {
                continue;
            }
            $result = $check['callback']();
            if ($result !== true) {
               $errors[] = $name . ': <br>' . $check['error'] . ' - ' . $result;
            }
        }
        if (!empty($errors)) {

            $this->response->statusCode(500);

            echo date('Y-m-d H:i:s') . ': ' . $this->_config['projectName'] . ' - ' . $this->_config['serverDescription'] . ' - Status Code: ' . $this->response->statusCode() . '<br><br> ';
            foreach ($errors as $error) {
                echo $error . '<br><br>';
            }
            die;
        }
        $this->_config['onSuccess']();
        die;
    }
331411
public function handle_cron_healthcheck() {
		if ( $this->is_process_running() ) {
			// Background process already running.
			exit;
		}

		if ( $this->is_queue_empty() ) {
			// No data to process.
			$this->clear_scheduled_event();
			exit;
		}

		$this->handle();

		exit;
	}
1284617
def set_checks(self, checks, position=None):
        """"""
        if position is None:
            position = self.position
        self.checkdefs[position][0] = checks
745958
def ok_check(function, *args, **kwargs):
    ''''''
    req = function(*args, **kwargs)
    if req.content.lower() != 'ok':
        raise ClientException(req.content)
    return req.content