def __send_messages(self, messages, sample_rates):
        """

        :type messages: list of Message
        :type sample_rates: list of int
        :param sample_rates: Sample Rate for each messages, this is needed to calculate the wait time,
                             as the pause for a message is given in samples
        :return:
        """
        self.is_sending = True
        sock = self.prepare_send_connection()
        if sock is None:
            return
        try:
            for i, msg in enumerate(messages):
                if self.__sending_interrupt_requested:
                    break
                assert isinstance(msg, Message)
                wait_time = msg.pause / sample_rates[i]

                self.current_send_message_changed.emit(i)
                error = self.send_data(self.bit_str_to_bytearray(msg.encoded_bits_str) + b"\n", sock)
                if not error:
                    logger.debug("Sent message {0}/{1}".format(i + 1, len(messages)))
                    logger.debug("Waiting message pause: {0:.2f}s".format(wait_time))
                    if self.__sending_interrupt_requested:
                        break
                    time.sleep(wait_time)
                else:
                    self.is_sending = False
                    Errors.generic_error("Could not connect to {0}:{1}".format(self.client_ip, self.client_port),
                                         msg=error)
                    break
            logger.debug("Sending finished")
            self.is_sending = False
        finally:
            self.shutdown_socket(sock)
def __send_messages ( self , messages , sample_rates ) : self . is_sending = True sock = self . prepare_send_connection ( ) if sock is None : return try : for i , msg in enumerate ( messages ) : if self . __sending_interrupt_requested : break assert isinstance ( msg , Message ) wait_time = msg . pause / sample_rates [ i ] self . current_send_message_changed . emit ( i ) error = self . send_data ( self . bit_str_to_bytearray ( msg . encoded_bits_str ) + b"\n" , sock ) if not error : logger . debug ( "Sent message {0}/{1}" . format ( i + 1 , len ( messages ) ) ) logger . debug ( "Waiting message pause: {0:.2f}s" . format ( wait_time ) ) if self . __sending_interrupt_requested : break time . sleep ( wait_time ) else : self . is_sending = False Errors . generic_error ( "Could not connect to {0}:{1}" . format ( self . client_ip , self . client_port ) , msg = error ) break logger . debug ( "Sending finished" ) self . is_sending = False finally : self . shutdown_socket ( sock )
:type messages: list of Message
        :type sample_rates: list of int
        :param sample_rates: Sample Rate for each messages, this is needed to calculate the wait time,
                             as the pause for a message is given in samples
        :return: