'Finalize the app.
This loads built-in tasks, evaluates pending task decorators,
reads configuration, etc.'

def finalize(self, auto=False):

    with self._finalize_mutex:
        if (not self.finalized):
            if (auto and (not self.autofinalize)):
                raise RuntimeError(u'Contract    breach:    app    not    finalized')
            self.finalized = True
            _announce_app_finalized(self)
            pending = self._pending
            while pending:
                maybe_evaluate(pending.popleft())
            for task in values(self._tasks):
                task.bind(self)
            self.on_after_finalize.send(sender=self)
