气流Web服务器由于错误的应用上下文烧瓶而终止

时间:2020-02-18 01:30:23

标签: python flask airflow

所以直到我在同一项目根目录下创建了Flask应用之前,我的Airflow的网络服务器都运行良好。

project/
  |
  -airflow_home/ # airflow dags, config, etc...
  |
  -app/
    |
    -__init__.py
    -models.py
    -config.py
    -routes.py
  |
  -manage.py

这是airflow-webserver错误:

airflow[19435]: app = cached_app_rbac(None) if settings.RBAC else cached_app(None)
airflow[19435]: File "/home/airflow/.local/lib/python3.7/site-packages/airflow/www/app.py", line 204, in cached_app
airflow[19435]: app = create_app(config, testing)
airflow[19435]: File "/home/airflow/.local/lib/python3.7/site-packages/airflow/www/app.py", line 186, in create_app
airflow[19435]: return app
airflow[19435]: File "/home/airflow/.local/lib/python3.7/site-packages/flask/ctx.py", line 249, in __exit__
airflow[19435]: self.pop(exc_value)
airflow[19435]: File "/home/airflow/.local/lib/python3.7/site-packages/flask/ctx.py", line 241, in pop
airflow[19435]: assert rv is self, "Popped wrong app context.  (%r instead of %r)" % (rv, self)
airflow[19435]: AssertionError: Popped wrong app context.  (<flask.ctx.AppContext object at 0x7fa117448d10> instead of <flask.ctx.AppContext object at 0x7fa18678f0d0>)

app / init .py

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import app.config as config

db = SQLAlchemy()


def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config_name)
    db.init_app(app)

    return app

manage.py

from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager
import app.config as config

from app import create_app, db

from app import models

app = create_app(config.Config)

app.app_context().push()

manager = Manager(app)

migrate = Migrate(app, db)

manager.add_command('db', MigrateCommand)

@manager.command
def run():
    app.run()

if __name__ == '__main__':
    manager.run()


0 个答案:

没有答案