示例#1
0
 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)
示例#2
0
文件: base.py 项目: zhouyuking/faust
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
示例#3
0
文件: base.py 项目: trauter/faust-1
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