gunicorn v20:从19.9.0升级以来出现的问题:Flask / Dash应用程序无法在'index'中找到应用程序对象'app.server'

问题描述 投票:0回答:1

基于Dash(https://plot.ly/dash)的我的应用程序,在我使用https://pypi.org/project/pur更新了库后停止工作了>

我没有注意,并且干姜从v19.9.0升级到v20.0.0

显然存在重大变化,但我不知道如何解决。有什么想法吗?

PS:我已经阅读了这篇文章,但对我没有帮助:https://github.com/benoitc/gunicorn/issues/2159

预先感谢您的帮助

错误

无法在“索引”中找到应用程序对象“ app.server”[INFO]关机:大师[INFO]原因:应用无法加载。

gunicorn命令:如果版本为v19.9.0,但工作版本为v20.0.0,则工作失败

gunicorn --bind=0.0.0.0 --timeout 600 index:app.server

index.py


# -*- coding: utf-8 -*-
from dash.dependencies import Input, Output
from webapp import app
import dash_core_components as dcc
import dash_html_components as html
import logging
import os
import sys
from pages import (
    overview,
)

try:
    app.index_string = open(os.path.join("html", "index.html")).read()
except OSError:
    logging.exception("load (%d): index.html not found" %
                      sys.exc_info()[-1].tb_lineno)
    sys.exit()

# Describe the layout/ UI of the app
app.layout = html.Div([
    dcc.Location(id="url", refresh=False),
    html.Div(id="page-content")
])


# Update page
@app.callback(Output("page-content", "children"),
              [Input("url", "pathname")])
def display_page(pathname):
    if pathname == "/a-service/overview":
        return overview.layout
    else:
        return overview.layout


if __name__ == "__main__":
    app.run_server(debug=True, port=8051)

webapp.py

# -*- coding: utf-8 -*-
import dash

description = "a description"
title = "a title"
creator = "@altf1be"
app = dash.Dash(
    __name__,

    meta_tags=[
        {"name": "viewport", "content": "width=device-width, initial-scale=1"},
        {"name": "description", "content": description},
        {"name": "twitter:description", "content": description},
        {"property": "og:title", "content": description},
        {"name": "twitter:creator", "content": creator}
    ]
)
server = app.server
app.config.suppress_callback_exceptions = True

我的应用程序基于Dash(https://plot.ly/dash),在我使用https://pypi.org/project/pur更新了我的库后,我停止了工作,我没有注意,并且将gunicorn从v19.9.0至v20.0.0。 ...

python gunicorn plotly-dash
1个回答
0
投票

Gunicorn 20更改了它解析和加载应用程序参数的方式。它曾经使用eval,其后是属性访问。现在,它仅对给定模块中的单个名称进行简单查找。 Gunicorn无法理解Python语法(例如,属性访问)的能力,也未记录。

Dash有关部署的文档没有使用您正在使用的语法。他们说要执行以下操作,这将适用于任何版本的Gunicorn:

© www.soinside.com 2019 - 2024. All rights reserved.