Loop forever, pinging someone every pass.
966915
def run(self, peer_table=None):
        
        self.running = True
        while self.running:
            local_inv = atlas_get_zonefile_inventory()
            t1 = time_now()
            self.step( peer_table=peer_table, local_inv=local_inv, path=self.atlasdb_path )
            t2 = time_now()

            # don't go too fast 
            if t2 - t1 < PEER_HEALTH_NEIGHBOR_WORK_INTERVAL:
                deadline = time_now() + PEER_HEALTH_NEIGHBOR_WORK_INTERVAL - (t2 - t1)
                while time_now() < deadline and self.running:
                    time_sleep( self.hostport, self.__class__.__name__, 1.0 )

                if not self.running:
                    break
243956
def ping(self, message=None):
        '''
        '''
        return self.write(self.parser.ping(message), encode=False)
1170041
def _send_loop(self):
        """"""
        while True:
            message, response_queue = self._send_queue.get()
            if message is self.STOP:
                break
            try:
                self._response_queues.put(response_queue)
                self._socket.send(message)
            except Exception:  # pylint:disable=broad-except
                log.exception("Exception sending message %s", message)
827232
function(data){
                    data = data || {timestamps:[]};
                    data.timestamps.push(new Date().getTime());
                    send(connection, "Ping", data);
                }
208178
def send_one_ping(self, current_socket):
        
        # Header is type (8), code (8), checksum (16), id (16), sequence (16)
        checksum = 0

        # Make a dummy header with a 0 checksum.
        header = struct.pack(
            "!BBHHH", ICMP_ECHO, 0, checksum, self.own_id, self.seq_number
        )

        padBytes = []
        startVal = 0x42
        for i in range(startVal, startVal + (self.packet_size)):
            padBytes += [(i & 0xff)]  # Keep chars in the 0-255 range
        data = bytes(padBytes)

        # Calculate the checksum on the data and the dummy header.
        checksum = calculate_checksum(header + data) # Checksum is in network order

        # Now that we have the right checksum, we put that in. It's just easier
        # to make up a new header than to stuff it into the dummy.
        header = struct.pack(
            "!BBHHH", ICMP_ECHO, 0, checksum, self.own_id, self.seq_number
        )

        packet = header + data

        send_time = default_timer()

        try:
            current_socket.sendto(packet, (self.destination, 1)) # Port number is irrelevant for ICMP
        except socket.error as e:
            print("General failure (%s)" % (e.args[1]))
            current_socket.close()
            return

        return send_time
570101
public void pingLoop() {
        if ( ! isStopped() ) {
            Log.Info(this, "----------- START MULTI RESPONSE REQUEST ------------");
            mediator.askSubscribers(self(), "defaultTopic", "Hello from " + myName,
                (reply, error) -> {
                    if (Actors.isComplete(error)) {
                        Log.Info(this,"----------- ALL RESULTS RECEIVED ------------");
                        delayed(5000, () -> pingLoop());
                    } else {
                        Log.Info(this,"=>" + reply);
                    }
                });
        }
    }
601736
def serve_forever(self, poll_interval=0.5):
        
        while self.is_alive:
            self.handle_request()
            time.sleep(poll_interval)
331784
function ping (){
    clearTimeout( ping.timer );
    ping.timer = setTimeout(function(){
      b9.send({ type: 'ping', time: Date.now() });
    }, b9._interval );
  }
271632
def stop(self):
        
        self.listener.setsockopt(LINGER, 1)
        self.loop = False
        with nslock:
            self.listener.close()
350016
public static void main(String[] args) {
        try {
            Twitter twitter = new TwitterFactory().getInstance();
            int page = 1;
            List<User> users;
            do {
                users = twitter.getBlocksList(page);
                for (User user : users) {
                    System.out.println("@" + user.getScreenName());
                }
                page++;
                // this code ends up in an infinite loop due to the issue 1988
                // http://code.google.com/p/twitter-api/issues/detail?id=1988
            } while (users.size() > 0 && page <= 10);
            System.out.println("done.");
            System.exit(0);
        } catch (TwitterException te) {
            te.printStackTrace();
            System.out.println("Failed to get blocking users: " + te.getMessage());
            System.exit(-1);
        }
    }
727753
def _run_forever(self):
        
        while True:
            try:
                tick = time.time()

                asyncore.loop(timeout=self.POLL_TIMEOUT, use_poll=True)

                # Sleep for remaining poll cycle time
                tick += self.POLL_TIMEOUT - time.time()
                if tick > 0:
                    # wait POLL_TIMEOUT at most (robust against time shifts)
                    time.sleep(min(tick, self.POLL_TIMEOUT))
            except KeyboardInterrupt as exc:
                self.LOG.info("Termination request received (%s)" % exc)
                break
            except SystemExit as exc:
                self.return_code = exc.code or 0
                self.LOG.info("System exit (RC=%r)" % self.return_code)
                break
            else:
                # Idle work
                #self.LOG.warn("IDLE %s %r" % (self.options.guard_file, os.path.exists(self.options.guard_file)))
                if self.options.guard_file and not os.path.exists(self.options.guard_file):
                    self.LOG.warn("Guard file '%s' disappeared, exiting!" % self.options.guard_file)
                    break
364621
public static void ping(String driver, String url, String user, String password) {
		try {
			Class.forName(driver);
			Connection connection = DriverManager.getConnection(url, user, password);
			connection.close();
		} catch (Exception e) {
			JKExceptionUtil.handle(e);
		}
	}
713537
protected void sendNextPing() {
		Set<String> nodeIDs = transporter.getAllNodeIDs();

		// Remove this node's ID
		nodeIDs.remove(nodeID);

		// Remove duplications by IP address
		int size = nodeIDs.size() * 2;
		HashSet<String> ips = new HashSet<>(size);
		Iterator<String> i = nodeIDs.iterator();
		while (i.hasNext()) {
			Tree descriptor = transporter.getDescriptor(i.next());
			if (descriptor == null) {
				continue;
			}
			Tree ipList = descriptor.get("ipList");
			if (ipList == null) {
				continue;
			}
			for (Tree ip : ipList) {
				if (ip == null) {
					continue;
				}
				String value = ip.asString();
				if (value == null || value.startsWith("127.")) {
					continue;
				}
				if (ips.contains(value)) {
					i.remove();
					break;
				}
				ips.add(value);
			}
			try {
				Thread.sleep(5);
			} catch (InterruptedException interrupt) {
				return;
			}
		}

		// Has peers?
		if (nodeIDs.isEmpty()) {
			return;
		}

		// Find the next nodeID
		boolean submitted = false;
		if (previousNodeID != null) {
			boolean found = false;
			for (String nextNodeID : nodeIDs) {
				if (previousNodeID.equals(nextNodeID)) {
					found = true;
					continue;
				}
				if (found && !nodeID.equals(nextNodeID)) {

					// Send PING to the next node
					submitted = true;
					previousNodeID = nextNodeID;
					sendPing(nextNodeID);
					break;
				}
			}
		}

		// Send PING to the first node
		if (!submitted) {
			for (String nextNodeID : nodeIDs) {
				if (!nodeID.equals(nextNodeID)) {
					previousNodeID = nextNodeID;
					sendPing(nextNodeID);
					break;
				}
			}
		}
	}
4004
public function tick()
    {
        while (!$this->queue->isEmpty() && $this->loop->isRunning())
        {
            $this->callback = $this->queue->dequeue();
            $callback = $this->callback; // without this proxy PHPStorm marks line as fatal error.
            $callback($this->loop);
        }
    }
1083949
private void pingMemberIfRequired(long now, Member member) {
        if (!icmpEnabled || icmpParallelMode) {
            return;
        }

        long lastHeartbeat = heartbeatFailureDetector.lastHeartbeat(member);
        if ((now - lastHeartbeat) >= legacyIcmpCheckThresholdMillis) {
            runPingTask(member);
        }
    }
733776
def ping(self, timeout=0, **kwargs):
        """"""

        # http://stackoverflow.com/a/2257449/5006
        def rand_id(size=8, chars=string.ascii_uppercase + string.digits):
            return ''.join(random.choice(chars) for _ in range(size))

        payload = rand_id()
        self.ws.ping(payload)
        opcode, data = self.recv_raw(timeout, [websocket.ABNF.OPCODE_PONG], **kwargs)
        if data != payload:
            raise IOError("Pinged server but did not receive correct pong")
996459
def polling_loop(connection)
      if polling?
        polling_msg = "Polling enabled. Checking every #{config.poll_interval} seconds."
      else
        polling_msg = "Polling disabled. Checking for messages once."
      end
      Mailman.logger.info(polling_msg)

      tries ||= 5
      loop do
        begin
          connection.connect
          connection.get_messages
        rescue SystemCallError, EOFError => e
          Mailman.logger.error e.message
          unless (tries -= 1).zero?
            Mailman.logger.error "Retrying..."
            begin
              connection.disconnect
            rescue # don't crash in the crash handler
            end
            retry
          end
        ensure
          connection.started? && connection.disconnect
        end

        break unless polling?
        sleep config.poll_interval
      end
    end