Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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