RQPython"Working outside of application context"

RQ Python "Working outside of application context"

我正在尝试使用 Redis 和 RQ 来设置发送电子邮件的任务,但是,"RQ Worker" 在使用向 q.enqueue 外部发送电子邮件的功能时返回运行时错误工作正常.

Which is outside the app folder

    from app import create_app

    app = create_app()

    if __name__ == '__main__':
        app.run(debug=True)

您可能漏掉了 app.app_context().push()。 Flask Mega 教程就像 this 一样,但我已经在任务中完成了。