'Runs the task with the loop items specified and collates the result
into an array named \'results\' which is inserted into the final result
along with the item for which the loop ran.'

def _run_loop(self, items):

    results = []
    task_vars = self._job_vars
    loop_var = 'item'
    label = None
    loop_pause = 0
    if self._task.loop_control:
        loop_var = (self._task.loop_control.loop_var or 'item')
        label = (self._task.loop_control.label or (('{{' + loop_var) + '}}'))
        loop_pause = (self._task.loop_control.pause or 0)
    if (loop_var in task_vars):
        display.warning((u"The    loop    variable    '%s'    is    already    in    use.    You    should    set    the    `loop_var`    value    in    the    `loop_control`    option    for    the    task    to    something    else    to    avoid    variable    collisions    and    unexpected    behavior." % loop_var))
    ran_once = False
    items = self._squash_items(items, loop_var, task_vars)
    for item in items:
        task_vars[loop_var] = item
        if (loop_pause and ran_once):
            time.sleep(loop_pause)
        else:
            ran_once = True
        try:
            tmp_task = self._task.copy(exclude_parent=True, exclude_tasks=True)
            tmp_task._parent = self._task._parent
            tmp_play_context = self._play_context.copy()
        except AnsibleParserError as e:
            results.append(dict(failed=True, msg=to_text(e)))
            continue
        (self._task, tmp_task) = (tmp_task, self._task)
        (self._play_context, tmp_play_context) = (tmp_play_context, self._play_context)
        res = self._execute(variables=task_vars)
        (self._task, tmp_task) = (tmp_task, self._task)
        (self._play_context, tmp_play_context) = (tmp_play_context, self._play_context)
        res[loop_var] = item
        res['_ansible_item_result'] = True
        if (label is not None):
            templar = Templar(loader=self._loader, shared_loader_obj=self._shared_loader_obj, variables=self._job_vars)
            res['_ansible_item_label'] = templar.template(label)
        self._rslt_q.put(TaskResult(self._host.name, self._task._uuid, res, task_fields=self._task.dump_attrs()), block=False)
        results.append(res)
        del task_vars[loop_var]
    return results
