def ping_neighbor(self):
        """used to ping neighbors periodically"""
        while True:
            # Go through all peers in the view
            for peer in self.replicas:
                successid = 0
                if peer == self.me:
                    continue
                # Check when last heard from peer
                if peer in self.nodeliveness:
                    nosound = time.time() - self.nodeliveness[peer]
                else:
                    # This peer did not send a message, send a PING
                    nosound = LIVENESSTIMEOUT + 1

                if nosound <= LIVENESSTIMEOUT:
                    # Peer is alive
                    self.replicas[peer] = 0
                    continue
                if nosound > LIVENESSTIMEOUT:
                    # Send PING to peer
                    if self.debug: self.logger.write("State", "Sending PING to %s" % str(peer))
                    pingmessage = create_message(MSG_PING, self.me)
                    successid = self.send(pingmessage, peer=peer)
                if successid < 0 or nosound > (2*LIVENESSTIMEOUT):
                    # The neighbor is not responding
                    if self.debug: self.logger.write("State",
                                                     "Neighbor not responding %s" % str(peer))
                    # Mark the neighbor
                    self.replicas[peer] += 1
                    # Check leadership
                    if not self.isleader and self.find_leader() == self.me:
                        if self.debug: self.logger.write("State",
                                                         "Becoming leader")
                        self.become_leader()
                    if self.isleader and \
                            peer not in self.nodesbeingdeleted and \
                            peer in self.replicas:
                        if self.debug: self.logger.write("State",
                                                         "Deleting node %s" % str(peer))
                        self.nodesbeingdeleted.add(peer)
                        delcommand = self.create_delete_command(peer)
                        self.pick_commandnumber_add_to_pending(delcommand)
                        for i in range(WINDOW):
                            noopcommand = self.create_noop_command()
                            self.pick_commandnumber_add_to_pending(noopcommand)
                        issuemsg = create_message(MSG_ISSUE, self.me)
                        self.send(issuemsg, peer=self.me)

            with self.recentlyupdatedpeerslock:
                self.recentlyupdatedpeers = []
            time.sleep(LIVENESSTIMEOUT)
dataset/ETHPy150Open denizalti/concoord/concoord/replica.py/Replica.ping_neighbor/original