keepalive probing
513068
public function keepaliveProbe() {
        if($this->keepalive_interval <=0 || $this->keepalive_timeout <=0){
            return ;
        }
        
        $this->keepalive_timer = Yii::$app->eventLooper->addInterval($this->keepalive_interval*1000, function($timerId, $interval, $flag, $args=null){
            $now = microtime(true);
            Yii::debug(" ...", 'beyod');
            foreach($this->connections as $id =>$conn){
                if($conn->request_at >0 && $conn->request_at < ($now - $this->keepalive_timeout)){
                    Yii::debug($conn." keepalive timed out,close it",'beyod');
                    $conn->close();
                }
            }
        });
    }
70032
private synchronized void scheduleKeepAlive(long lastKeepAliveTime, long timeout, long delta) {
    Scheduled keepAliveFuture = keepAliveTimers.remove(timeout);
    if (keepAliveFuture != null) {
      keepAliveFuture.cancel();
    }

    // Schedule the keep alive for 3/4 the timeout minus the delta from the last keep-alive request.
    keepAliveTimers.put(timeout, threadContext.schedule(Duration.ofMillis(Math.max(Math.max((long) (timeout * TIMEOUT_FACTOR) - delta, timeout - MIN_TIMEOUT_DELTA - delta), 0)), () -> {
      if (open.get()) {
        keepAliveSessions(lastKeepAliveTime, timeout);
      }
    }));
  }
935732
public static boolean isKeepAlive(KeepAliveConfig keepAliveConfig, HttpCarbonMessage outboundRequestMsg)
            throws ConfigurationException {
        switch (keepAliveConfig) {
        case AUTO:
            return Float.valueOf((String) outboundRequestMsg.getProperty(Constants.HTTP_VERSION)) > Constants.HTTP_1_0;
        case ALWAYS:
            return true;
        case NEVER:
            return false;
        default:
            // The execution will never reach here. In case execution reach here means it should be an invalid value
            // for keep-alive configurations.
            throw new ConfigurationException("Invalid keep-alive configuration value : "
                    + keepAliveConfig.toString());
        }
    }
700011
boolean isKeepaliveAllowed(long connectionStartTime)
  {
    if (! _lifecycle.isActive()) {
      return false;
    }
    else if (connectionStartTime + _keepaliveTimeMax < CurrentTime.currentTime()) {
      return false;
    }
    else if (_keepaliveMax <= _keepaliveAllocateCount.get()) {
      return false;
    }
    /*
    else if (_connThreadPool.isThreadMax()
             && _connThreadPool.isIdleLow()
             && ! isKeepaliveAsyncEnabled()) {
      return false;
    }
    */
    else {
      return true;
    }
  }
548744
def watch_record(indexer, use_polling=False):
    
    if use_polling:
        from watchdog.observers.polling import PollingObserver as Observer
        Observer  # fool pyflakes
    else:
        from watchdog.observers import Observer

    event_handler = RecordHandler(indexer)
    observer = Observer()
    observer.schedule(event_handler, path=indexer.record_path, recursive=True)
    indexer.logger.debug('Start observer.')
    observer.start()
    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        indexer.logger.debug('Got KeyboardInterrupt. Stopping observer.')
        observer.stop()
    indexer.logger.debug('Joining observer.')
    observer.join()
    indexer.logger.debug('Finish watching record.')
377767
def probe_sync(self):
        """"""

        done = threading.Event()
        result = {}

        def probe_done(adapter_id, status, reason):
            result['success'] = status
            result['failure_reason'] = reason
            done.set()

        self.probe_async(probe_done)
        done.wait()

        return result
967261
def _keepalive(self):
        
        try:
            keptalive = False
            if self._customkeepalives:
                kaids = list(self._customkeepalives.keys())
                for keepalive in kaids:
                    try:
                        cmd, callback = self._customkeepalives[keepalive]
                    except TypeError:
                        # raw_command made customkeepalives None
                        break
                    except KeyError:
                        # raw command ultimately caused a keepalive to
                        # deregister
                        continue
                    if callable(cmd):
                        cmd()
                        continue
                    keptalive = True
                    cmd['callback'] = self._keepalive_wrapper(callback)
                    self.raw_command(**cmd)
            if not keptalive:
                if self.incommand:
                    # if currently in command, no cause to keepalive
                    return
                self.raw_command(netfn=6, command=1,
                                 callback=self._keepalive_wrapper(None))
        except exc.IpmiException:
            self._mark_broken()
283825
def probe_git():
    """"""
    try:
        repo = git.Repo()
    except git.InvalidGitRepositoryError:
        LOGGER.warning(
            "We highly recommend keeping your model in a git repository."
            " It allows you to track changes and to easily collaborate with"
            " others via online platforms such as https://github.com.\n")
        return
    if repo.is_dirty():
        LOGGER.critical(
            "Please git commit or git stash all changes before running"
            " the memote suite.")
        sys.exit(1)
    return repo
759091
def patch_keepalive_run():
    
    _run = luigi.worker.KeepAliveThread.run

    def run(self):
        # do not run the keep-alive loop when sandboxed
        if os.getenv("LAW_SANDBOX_SWITCHED") == "1":
            self.stop()
        else:
            _run(self)

    luigi.worker.KeepAliveThread.run = run
426250
function resetKeepAlive() {
    if (keepAliveTimeoutId) {
        clearTimeout(keepAliveTimeoutId);
    }

    keepAliveTimeoutId = setTimeout(function () {
        exit.call(process, 1);
    }, keepAliveTimeout);
}
406260
private void stopRoundTripMeasurement() {
        if (keepAliveTask != null) {
            boolean cancelled = keepAliveTask.cancel(true);
            keepAliveTask = null;
            if (cancelled && log.isDebugEnabled()) {
                log.debug("Keep alive was cancelled for {}", sessionId);
            }
        }
    }
539489
public function keepAlive()
    {
        $loop = \React\EventLoop\Factory::create();
        $loop->addPeriodicTimer(30, function () {
            $listenKey = $this->listenKey;
            $this->httpRequest("v1/userDataStream?listenKey={$listenKey}", "PUT", []);
        });
        $loop->run();
    }
379301
def keep_alive(self):

		'''
		
		'''

		# keep transaction alive
		txn_response = self.api.http_request('POST','%sfcr:tx' % self.root, data=None, headers=None)

		# if 204, transaction kept alive
		if txn_response.status_code == 204:
			logger.debug("continuing transaction: %s" % self.root)
			# update status and timer
			self.active = True
			self.expires = txn_response.headers['Expires']
			return  True

		# if 410, transaction does not exist
		elif txn_response.status_code == 410:
			logger.debug("transaction does not exist: %s" % self.root)
			self.active = False
			return False

		else:
			raise Exception('HTTP %s, could not continue transaction' % txn_response.status_code)
646233
async def probe(self):
        

        resp = await self._execute(self._adapter.probe_sync)
        _raise_error(None, 'probe', resp)
291123
def keep_scan(cls, result_key, token):
        
        def _scan(self):
            return self.get(token)

        cls.scan(result_key, _scan)
233643
@Deprecated
  public final NettyChannelBuilder enableKeepAlive(boolean enable, long keepAliveTime,
      TimeUnit delayUnit, long keepAliveTimeout, TimeUnit timeoutUnit) {
    if (enable) {
      return keepAliveTime(keepAliveTime, delayUnit)
          .keepAliveTimeout(keepAliveTimeout, timeoutUnit);
    }
    return keepAliveTime(KEEPALIVE_TIME_NANOS_DISABLED, TimeUnit.NANOSECONDS);
  }
864535
public void save(ProbeTestRun probeTestRun) throws IOException {
		OutputStreamWriter osw = new OutputStreamWriter(
			new FileOutputStream(new File(getTmpDir(probeTestRun), UUID.randomUUID().toString())),
			Charset.forName(Constants.ENCODING).newEncoder()
		);
		
		serializer.serializePayload(osw, probeTestRun, true);
	}