def task_list(self, pending=True):
        """
        Return the list of scoped tasks (ie tasks that have
        appropriate roles set) in correct execution order.

        The result is a list of task objects.
    """
        log = self._params.get('log', self._discard)
        tasks = [t for t in self._tasks if t.participant()]
        requires = {}
        for t in tasks:
            requires[t] = t.get_requires(pending=pending)
        done = set()
        start_order = []
        cycle = 0
        while len(tasks) > len(start_order):
            cycle += 1
            changed = False
            for t in tasks:
                if t._name in done:
                    continue
                needs = 0
                for req in requires[t]:
                    if req._name in done:
                        needs += 1
                if needs == len(requires[t]):
                    changed = True
                    start_order.append(t)
                    done.add(t._name)
                    log.debug("Found '%s' in scope", t._name)
            if not changed:
                log.error("Cycle %d failed after %s", cycle, [t._name for t in set(tasks).difference(done)])
                raise TaskError(None, "At cycle %d, startup order conflict, processed %s, remaining %s" %
                            (cycle, done, [t._name for t in set(tasks).difference(done)]))
        log.debug("Cycle %d gave %s", cycle, [t._name for t in start_order])
        return start_order