Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gunicorn v20 : issue since the upgrade : Flask/Dash app Failed to find application object 'app.server' in 'index' #2175

Closed
Abdelkrim opened this issue Nov 15, 2019 · 15 comments

Comments

@Abdelkrim
Copy link

Abdelkrim commented Nov 15, 2019

My app, based on Dash (https://plot.ly/dash/), stopped working after I updated my libraries by using https://pypi.org/project/pur

I didn't pay attention and gunicorn upgraded from v19.9.0 to v20.0.0.

There is clearly a breaking change but I don't know how to address it. Any thought?

PS: I have read this post but it didn't help me : #2159

thank in advance for your help

The Error

Failed to find application object 'app.server' in 'index'
[INFO] Shutting down: Master
[INFO] Reason: App failed to load.

gunicorn command : working version if v19.9.0 but fails with 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
@Abdelkrim Abdelkrim changed the title v20 : issue since the upgrade : Flsak/Dash app Failed to find application object 'app.server' in 'index' gunicorn v20 : issue since the upgrade : Flask/Dash app Failed to find application object 'app.server' in 'index' Nov 15, 2019
@benoitc
Copy link
Owner

benoitc commented Nov 15, 2019

can you start gunicorn with the debug level to see where the application is failing?

@r-chris
Copy link

r-chris commented Nov 15, 2019

Exact same issue here - I'll take a closer look soon

@benoitc benoitc self-assigned this Nov 15, 2019
@benoitc benoitc added this to the 20.0.1 milestone Nov 15, 2019
@junnplus
Copy link
Contributor

I think it related to this change: 3701ad9#diff-0b90f794c3e9742c45bf484505e3db8dR377
same issue as: #2159

@jamadden
Copy link
Collaborator

Try using a simple name instead of expecting gunicorn to traverse into objects. For example, webapp:server.

@mjclawar
Copy link

Try using a simple name instead of expecting gunicorn to traverse into objects. For example, webapp:server.

This also worked as a fix for me (changed gunicorn app:app.server to gunicorn app:server after adding a line to app.py that declared server = app.server)

@jakegt1
Copy link

jakegt1 commented Nov 16, 2019

I assume from now on this kind of thing will also never work:

gunicorn module.app:create_app()

@Abdelkrim
Copy link
Author

Hi folks, here are the results of diverse attempts:

  • index:app.server - module 'index' has no attribute 'app.server'
  • index:app - Application object must be callable.
  • index:app.layout - crashes
  • index - AttributeError: module 'index' has no attribute 'application'

Still need to test those combinations:

  • webapp:server
  • index:server
  • index.app:server

@benoitc
Copy link
Owner

benoitc commented Nov 20, 2019

@Abdelkrim with latest master?

@Abdelkrim
Copy link
Author

@benoitc, I am running the v20.0.0 and not your latest update I am afraid

when will the latest update be available by using pip?

I do use Azure pipeline to deploy the web app and I don't know how to force the usage of the latest version of the code hosted on gituhub instead of using the regular requirements.txt

QUESTION: should I just wait a new version number? ... I'll deploy a new version of the code and give you my feedback (it requires ~1 hour => around 1:00am Brussels time)

@benoitc
Copy link
Owner

benoitc commented Nov 20, 2019

if you can test with the latest master that would help :) i will see if i reproduce it later this morning otherwise

@Abdelkrim
Copy link
Author

@benoitc I can't access to the machine using ssh and force the usage of the latest version of gunicorn.

QUESTION : do you know how/when the latest release will be available on PyPi? I see this : Last released: Nov 9, 2019 on https://pypi.org/project/gunicorn

this will greatly facilitate my testing as I don't have access to any linux machine besides the Linux web apps on Azure :-(

Kind regards & thank you all for the time you have invested in this case

@benoitc
Copy link
Owner

benoitc commented Nov 21, 2019

@Abdelkrim the following commandline works:

gunicorn -w3 --pythonpath="/path/to/gunicorn/examples" deep.test:app

with the following example: https://github.com/benoitc/gunicorn/tree/master/examples/deep . I'm closing the issue then. The release will land today hopefully.

@benoitc benoitc closed this as completed Nov 21, 2019
@Abdelkrim
Copy link
Author

@benoitc thank you, I'm waiting for the latest release and I'll give you my feedback.

many thanks for your help

A.

@vytas7
Copy link
Contributor

vytas7 commented Nov 23, 2019

Confirmed fixed with the latest master, thanks!
(Although it wouldn't have been a big deal to adapt in our case if it was an architectural decision)

Edit: A fun fact, I happened to test with Git master just a couple of minutes before 20.0.1 hit PyPi 🙂

@Abdelkrim
Copy link
Author

@benoitc @davidism I wanted to thank you for the support. the app works using gunicorn v20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants