def handle_messages(self):
        while True:
            self.receivedmessages_semaphore.acquire()
            (message_to_process,connection) = self.receivedmessages.pop(0)
            if message_to_process.type == MSG_CLIENTREQUEST:
                if message_to_process.clientbatch:
                    self.process_message(message_to_process, connection)
                    continue
                # check if there are other client requests waiting
                msgconns = [(message_to_process,connection)]
                for m,c in self.receivedmessages:
                    if m.type == MSG_CLIENTREQUEST:
                        # decrement the semaphore count
                        self.receivedmessages_semaphore.acquire()
                        # remove the m,c pair from receivedmessages
                        self.receivedmessages.remove((m,c))
                        msgconns.append((m,c))
                if len(msgconns) > 1:
                    self.process_messagelist(msgconns)
                else:
                    self.process_message(message_to_process, connection)
            else:
                self.process_message(message_to_process, connection)
        return
dataset/ETHPy150Open denizalti/concoord/concoord/node.py/Node.handle_messages/original