app.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:kostyor 作者: Mirantis 项目源码 文件源码
def create_app(conf):
    app = celery.Celery()

    for option, value in conf.rpc.items():
        # celery options are upper-cased, just like in flask
        app.conf[option.upper()] = value

    # Each driver may use own set of Celery tasks, so in order to run them
    # the Celery worker has to load them into memory. That's why we need to
    # iterate over Kostyor drivers and lazily load them into memory. The
    # important note here is that we can't use stevedore because it tries
    # to load found module immediately which leads to cyclic import error
    # (drivers import a celery app in order to define own tasks).
    namespaces = (
        'kostyor.upgrades.drivers',
        'kostyor.discovery_drivers',
    )

    for namespace in namespaces:
        for ep in pkg_resources.iter_entry_points(namespace):
            package, module = ep.module_name.rsplit('.', 1)
            app.autodiscover_tasks([package], module)

    return app
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号