'Internal version of flush() with no locking.'

def _flush(self):

    logs = self.parse_logs()
    self._clear()
    while True:
        group = log_service_pb.UserAppLogGroup()
        byte_size = 0
        n = 0
        for (timestamp_usec, level, message, unused_source_location) in logs:
            message = self._truncate(message, self._MAX_LINE_SIZE)
            if ((byte_size + len(message)) > self._MAX_FLUSH_SIZE):
                break
            line = group.add_log_line()
            line.set_timestamp_usec(timestamp_usec)
            line.set_level(level)
            line.set_message(message)
            byte_size += (1 + group.lengthString(line.ByteSize()))
            n += 1
        assert ((n > 0) or (not logs))
        logs = logs[n:]
        request = log_service_pb.FlushRequest()
        request.set_logs(group.Encode())
        response = api_base_pb.VoidProto()
        apiproxy_stub_map.MakeSyncCall('logservice', 'Flush', request, response)
        if (not logs):
            break
