Create a timer that will be used to periodically check the
        connection for heartbeats.

        :return:
163714
def _start_new_timer(self):
        
        if not self._running.is_set():
            return False
        self._timer = self.timer_impl(
            interval=self._interval,
            function=self._check_for_life_signs
        )
        self._timer.daemon = True
        self._timer.start()
        return True
657785
boolean onHeartbeatStop()
  {
    SocketPool clusterSocketPool;
    
    if (isExternal()) {
      clusterSocketPool = _clusterSocketPool.getAndSet(null);
    }
    else {
      clusterSocketPool = _clusterSocketPool.get();
    }

    if (clusterSocketPool != null) {
      clusterSocketPool.getFactory().notifyHeartbeatStop();
    }

    /*
    if (! _heartbeatState.notifyHeartbeatStop()) {
      return false;
    }
    */
    
    log.fine("notify-heartbeat-stop " + this);

    return true;
  }
1289083
def _Start_refresh_timer(self):
		
		if self._refreshPeriod > 60:
			interval = self._refreshPeriod - 60
		else:
			interval = 60
		self._refreshTimer = Timer(self._refreshPeriod, self.Refresh)
		# TODO:handle exit and logout active connections. revert from daemon then
		self._refreshTimer.setDaemon(True)
		self._refreshTimer.start()
543127
void heartbeat() {
        if (!clusterService.isJoined()) {
            return;
        }

        checkClockDrift(heartbeatIntervalMillis);

        final long clusterTime = clusterClock.getClusterTime();
        if (clusterService.isMaster()) {
            heartbeatWhenMaster(clusterTime);
        } else {
            heartbeatWhenSlave(clusterTime);
        }
    }
254031
def _monitor(last_ping, stop_plugin, is_shutting_down, timeout=5):
    
    _timeout_count = 0
    _last_check = time.time()
    _sleep_interval = 1
    # set _sleep_interval if less than the timeout
    if timeout < _sleep_interval:
        _sleep_interval = timeout
    while True:
        time.sleep(_sleep_interval)
        # Signals that stop_plugin has been called
        if is_shutting_down():
            return
        # have we missed a ping during the last timeout duration
        if ((time.time() - _last_check) > timeout) and ((time.time() - last_ping()) > timeout):
            # reset last_check
            _last_check = time.time()
            _timeout_count += 1
            LOG.warning("Missed ping health check from the framework. " +
                        "({} of 3)".format(_timeout_count))
            if _timeout_count >= 3:
                stop_plugin()
                return
        elif (time.time() - last_ping()) <= timeout:
            _timeout_count = 0
210842
def send_heart_beat_msg(self):
        ''''''
        if self.running:
            self.do_get_parameter()
            threading.Timer(HEARTBEAT_INTERVAL, self.send_heart_beat_msg).start()
740365
def heartbeat(self, context, msg):
        """"""

        args = jsonutils.loads(msg)
        when = args.get('when')
        agent = args.get('agent')
        # The configurations in here, only used once when creating entry
        # for an agent in DB for the first time.
        configurations = {'uplink': ''}
        LOG.debug('heartbeat received: %(time)s - %(agent)s', (
                  {'time': when, 'agent': agent}))

        if self.obj.neutron_event:
            self.obj.neutron_event.create_rpc_client(agent)
        # Other option is to add the event to the queue for processig it later.

        self.obj.update_agent_status(agent, when)

        # Update the agents database.
        agent_info = dict(timestamp=utils.utc_time(when), host=agent,
                          config=jsonutils.dumps(configurations))
        self.obj.update_agent_db(agent_info)
1128255
def heartbeat(self, min_interval=0):
        
        if not self._heartbeat:
            self._heartbeat = _PublisherHeartbeat(self)
        self._heartbeat(min_interval)
74499
def run(self):
        

        self.__timer = QTimer()
        self.__timer.moveToThread(self)
        self.__timer.start(Constants.default_timer_cycle * self.__timer_cycle_multiplier)

        self.__timer.timeout.connect(self.__watch_file_system, Qt.DirectConnection)

        self.exec_()
522670
def run(self):
        
        try:
            self.initialize_connection()
        except ChromecastConnectionError:
            self._report_connection_status(
                ConnectionStatus(CONNECTION_STATUS_DISCONNECTED,
                                 NetworkAddress(self.host, self.port)))
            return

        self.heartbeat_controller.reset()
        self._force_recon = False
        logging.debug("Thread started...")
        while not self.stop.is_set():

            if self.run_once() == 1:
                break

        # Clean up
        self._cleanup()
919662
def install_timers(config, context):
    """"""
    timers = []
    if config.get('capture_timeout_warnings'):
        timeout_threshold = config.get('timeout_warning_threshold')
        # Schedule the warning at the user specified threshold given in percent.
        # ie: 0.50 of 30000 ms = 15000ms
        # Schedule the error a few milliseconds before the actual timeout happens.
        time_remaining = context.get_remaining_time_in_millis() / 1000
        timers.append(Timer(time_remaining * timeout_threshold, timeout_warning, (config, context)))
        timers.append(Timer(max(time_remaining - .5, 0), timeout_error, [config]))

    if config.get('capture_memory_warnings'):
        # Schedule the memory watch dog interval. Warning will re-schedule itself if necessary.
        timers.append(Timer(.5, memory_warning, (config, context)))

    for t in timers:
        t.start()

    return timers
169164
def tick(self):
        """"""
        try:
            s, addr = self.socket.accept()
            if not self.ready:
                return
            
            prevent_socket_inheritance(s)
            if hasattr(s, 'settimeout'):
                s.settimeout(self.timeout)
            
            makefile = CP_fileobject
            ssl_env = {}
            # if ssl cert and key are set, we try to be a secure HTTP server
            if self.ssl_adapter is not None:
                try:
                    s, ssl_env = self.ssl_adapter.wrap(s)
                except NoSSLError:
                    msg = ("The client sent a plain HTTP request, but "
                           "this server only speaks HTTPS on this port.")
                    buf = ["%s 400 Bad Request\r\n" % self.protocol,
                           "Content-Length: %s\r\n" % len(msg),
                           "Content-Type: text/plain\r\n\r\n",
                           msg]
                    
                    wfile = CP_fileobject(s, "wb", DEFAULT_BUFFER_SIZE)
                    try:
                        wfile.sendall("".join(buf))
                    except socket.error, x:
                        if x.args[0] not in socket_errors_to_ignore:
                            raise
                    return
                if not s:
                    return
                makefile = self.ssl_adapter.makefile
                # Re-apply our timeout since we may have a new socket object
                if hasattr(s, 'settimeout'):
                    s.settimeout(self.timeout)
            
            conn = self.ConnectionClass(self, s, makefile)
            
            if not isinstance(self.bind_addr, basestring):
                # optional values
                # Until we do DNS lookups, omit REMOTE_HOST
                if addr is None: # sometimes this can happen
                    # figure out if AF_INET or AF_INET6.
                    if len(s.getsockname()) == 2:
                        # AF_INET
                        addr = ('0.0.0.0', 0)
                    else:
                        # AF_INET6
                        addr = ('::', 0)
                conn.remote_addr = addr[0]
                conn.remote_port = addr[1]
            
            conn.ssl_env = ssl_env
            
            self.requests.put(conn)
        except socket.timeout:
            # The only reason for the timeout in start() is so we can
            # notice keyboard interrupts on Win32, which don't interrupt
            # accept() by default
            return
        except socket.error, x:
            if x.args[0] in socket_error_eintr:
                # I *think* this is right. EINTR should occur when a signal
                # is received during the accept() call; all docs say retry
                # the call, and I *think* I'm reading it right that Python
                # will then go ahead and poll for and handle the signal
                # elsewhere. See http://www.cherrypy.org/ticket/707.
                return
            if x.args[0] in socket_errors_nonblocking:
                # Just try again. See http://www.cherrypy.org/ticket/479.
                return
            if x.args[0] in socket_errors_to_ignore:
                # Our socket was closed.
                # See http://www.cherrypy.org/ticket/686.
                return
            raise
742963
def start_heartbeat(self):
        

        if not self._hb_thread:

            try:

                self._logger.info('Starting heartbeat thread')
                self._prof.prof('creating heartbeat thread', uid=self._uid)
                self._hb_terminate = threading.Event()
                self._hb_thread = threading.Thread(target=self._heartbeat, name='heartbeat')

                self._prof.prof('starting heartbeat thread', uid=self._uid)
                self._hb_thread.start()

                return True

            except Exception, ex:

                self._logger.exception('Heartbeat not started, error: %s' % ex)
                self.terminate_heartbeat()
                raise

        else:
            self._logger.warn('Heartbeat thread already running, but attempted to restart!')
1357534
def heartbeat(self):
        
        if self._rpc is not None and self._rpc.is_active:
            self._rpc.send(types.StreamingPullRequest())
567929
def send_heartbeat(self, name):
        

        return self._loop.run_coroutine(self._client.send_heartbeat(name))
596800
def restart_inactivity_timer
      @inactivity_timer.cancel if @inactivity_timer
      @inactivity_timer = EM::Timer.new(@check_interval) do
        begin
          check(id = nil, max_ping_timeouts = 1)
        rescue Exception => e
          ErrorTracker.log(self, "Failed connectivity check", e)
        end
      end
      true
    end
348296
private void scheduleHeartbeat()
  {
    // elapsed time in seconds since the last heartbeat
    long elapsedSecsSinceLastHeartBeat =
        System.currentTimeMillis() / 1000 - lastHeartbeatStartTimeInSecs;

    /*
     * The initial delay for the new scheduling is 0 if the elapsed
     * time is more than the heartbeat time interval, otherwise it is the
     * difference between the heartbeat time interval and the elapsed time.
     */
    long initialDelay = Math.max(heartBeatIntervalInSecs -
                                 elapsedSecsSinceLastHeartBeat, 0);

    LOGGER.debug(
        "schedule heartbeat task with initial delay of {} seconds",
        initialDelay);

    // Creates and executes a periodic action to send heartbeats
    this.heartbeatFuture =
        this.scheduler.schedule(this, initialDelay, TimeUnit.SECONDS);
  }