def _process_queue_tasks(self, queue, queue_lock, task_ids, now, log):
        """Process tasks in queue."""

        processed_count = 0

        # Get all tasks
        serialized_tasks = self.connection.mget([
            self._key('task', task_id) for task_id in task_ids
        ])

        # Parse tasks
        tasks = []
        for task_id, serialized_task in zip(task_ids, serialized_tasks):
            if serialized_task:
                task_data = json.loads(serialized_task)
            else:
                # In the rare case where we don't find the task which is
                # queued (see ReliabilityTestCase.test_task_disappears),
                # we log an error and remove the task below. We need to
                # at least initialize the Task object with an ID so we can
                # remove it.
                task_data = {'id': task_id}

            task = Task(self.tiger, queue=queue, _data=task_data,
                        _state=ACTIVE, _ts=now)

            if not serialized_task:
                # Remove task as per comment above
                log.error('not found', task_id=task_id)
                task._move()
            elif task.id != task_id:
                log.error('task ID mismatch', task_id=task_id)
                # Remove task
                task._move()
            else:
                tasks.append(task)

        # List of task IDs that exist and we will update the heartbeat on.
        valid_task_ids = set(task.id for task in tasks)

        # Group by task func
        tasks_by_func = OrderedDict()
        for task in tasks:
            func = task.serialized_func
            if func in tasks_by_func:
                tasks_by_func[func].append(task)
            else:
                tasks_by_func[func] = [task]

        # Execute tasks for each task func
        for tasks in tasks_by_func.values():
            success, processed_tasks = self._execute_task_group(queue,
                    tasks, valid_task_ids, queue_lock)
            processed_count = processed_count + len(processed_tasks)
            log.debug('processed', attempted=len(tasks),
                      processed=processed_count)
            for task in processed_tasks:
                self._finish_task_processing(queue, task, success)

        return processed_count
Process tasks in queue.