def _on_ready_to_send(self, conn_id, sent_length):
        conn = self._connections[conn_id]
        conn.send_in_progress = False

        conn.send_buffer.cut(sent_length)
        while sent_length > 0:
            first, packet_id = conn.queued_packet_ids.popleft()
            if first <= sent_length:
                self.on_packet_sent(conn_id, packet_id)
            else:
                conn.queued_packet_ids.appendleft((first - sent_length,
                                                packet_id))
            sent_length -= first

        self._send_to_link(conn_id, conn)

    ###########################################################
dataset/ETHPy150Open dsiroky/snakemq/snakemq/packeter.py/Packeter._on_ready_to_send/original