def _finalize_concrete_app(self, app: AppT) -> AppT: app.finalize() # XXX How to find full argv[0] with click? origin = app.conf.origin if sys.argv: origin = self._detect_main_package(sys.argv) return prepare_app(app, origin)
def prepare_app(app: AppT, name: Optional[str]) -> AppT: app.finalize() if app.conf.origin is None: app.conf.origin = name if app.conf.autodiscover: app.discover() # Hack to fix cProfile support. main = sys.modules.get('__main__') if main is not None and 'cProfile.py' in getattr(main, '__file__', ''): from ..models import registry registry.update({(app.conf.origin or '') + k[8:]: v for k, v in registry.items() if k.startswith('cProfile.')}) return app
def prepare_app(app: AppT, name: Optional[str]) -> AppT: app.finalize() if app.conf._origin is None: app.conf._origin = name app.worker_init() if app.conf.autodiscover: app.discover() app.worker_init_post_autodiscover() # Hack to fix cProfile support. if 1: # pragma: no cover main = sys.modules.get("__main__") if main is not None and "cProfile.py" in getattr(main, "__file__", ""): from ..models import registry registry.update({(app.conf.origin or "") + k[8:]: v for k, v in registry.items() if k.startswith("cProfile.")}) return app