'Internal implementation of delete_tasks_async(), tasks must be a list.'

def __DeleteTasks(self, tasks, multiple, rpc=None):

    def ResultHook(rpc):
        'Process    the    TaskQueueDeleteResponse.'
        try:
            rpc.check_success()
        except apiproxy_errors.ApplicationError as e:
            raise _TranslateError(e.application_error, e.error_detail)
        assert (rpc.response.result_size() == len(tasks)), ('expected    %d    results    from    delete(),    got    %d' % (len(tasks), rpc.response.result_size()))
        IGNORED_STATES = [taskqueue_service_pb.TaskQueueServiceError.UNKNOWN_TASK, taskqueue_service_pb.TaskQueueServiceError.TOMBSTONED_TASK]
        exception = None
        for (task, result) in zip(tasks, rpc.response.result_list()):
            if (result == taskqueue_service_pb.TaskQueueServiceError.OK):
                task._Task__deleted = True
            elif (result in IGNORED_STATES):
                task._Task__deleted = False
            elif (exception is None):
                exception = _TranslateError(result)
        if (exception is not None):
            raise exception
        if multiple:
            return tasks
        else:
            assert (len(tasks) == 1)
            return tasks[0]
    request = taskqueue_service_pb.TaskQueueDeleteRequest()
    response = taskqueue_service_pb.TaskQueueDeleteResponse()
    request.set_queue_name(self.__name)
    task_names = set()
    for task in tasks:
        if (not task.name):
            raise BadTaskStateError('Task    name    must    be    specified    for    a    task')
        if task.was_deleted:
            raise BadTaskStateError(('Task    %s    has    already    been    deleted' % task.name))
        if (task.name in task_names):
            raise DuplicateTaskNameError(('The    task    name    %r    is    used    more    than    once    in    the    request' % task.name))
        task_names.add(task.name)
        request.add_task_name(task.name)
    return _MakeAsyncCall('Delete', request, response, ResultHook, rpc)
