Black Lives Matter. Please consider donating to Black Girls Code today.

Uwsgi / Flask / layout not loading on multi-app setup

A few months ago, probably because of an Ubuntu and Uwsgi upgrade, our dash apps stopped working. Getting logs has been difficult but I think I’ve narrowed it down to the layout not loading, and the main module not working. Executing python runner.py works fine but not from uwsgi.

@chriddyp gave me the advice last year about handling multi apps, but I wonder if my runner.py is now out of date? Setup and code below

runner.py

import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output

import sys

from app import app
# The name ("application") must match the "callable" in the uwsgi .ini file
from app import server as application

# Import the apps from the apps folder based on filename
from apps import line, beehives, sr_by_over
#from apps.bounce_graph import app as bounce_graph_app

sys.path.insert(0, "/home/repos/blah/app")

app.layout = html.Div([
    dcc.Location(id='url', refresh=False),
    html.Div(id='page-content')
])


@app.callback(Output('page-content', 'children'),
              [Input('url', 'pathname')])
def display_page(pathname):
    if pathname == '/graph/line_graph':
        return line.layout
    elif pathname == '/graph/beehives':
        # Layouts must be served as a function to get fresh data. This needs
        # caching with DiskCache.
        layout = beehives.get_layout()[1]
        return layout
    # elif pathname == '/graph/bounce_graph':
    #     return bounce_graph_app.get_layout()[0]
    elif pathname == '/graph/sr_by_over':
        return sr_by_over.layout
    else:
        return 'Loading ...'


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

My uwsgi.ini looks like this:

[uwsgi]
master = true
socket = 127.0.0.1:5569
processes = 4
threads = 1
thunder-lock = false

chdir = /home/blah/repos/blah/app
module = runner
callable = application
home = /home/blah/VirtualEnvs/blah

limit-as = 1024
max-requests = 10000
harakiri = 360
vacuum = true
touch-reload = /home/blah/uwsgi-reload/graph

memory-report
stats = /tmp/graph-stats.socket

req-logger = file:/var/log/uwsgi/graph-access.log
logger = file:/var/log/uwsgi/graph-error.log
logformat = %(addr) - %(user) [%(ltime)] "%(method) %(uri) %(proto)" %(status) %(size) "%(referer)" "%(uagent)"

Uwsgi usually just complains of segmentation fault and it’s been impossible to diagnose further. But the layout not loading does seem to be the root cause. Can anyone spot anything wrong here? (Edit: versions etc below)

Python 3.6.6
Flask 1.0.2
Flask-Caching 1.3.3
Flask-Compress 1.4.0
Flask-SeaSurf 0.2.2
dash 0.26.4
dash-core-components 0.28.2
dash-html-components 0.12.0
dash-renderer 0.13.2
plotly 3.2.0

I know these are all out of date, but have tried upgrading them all which hasn’t helped.

Thanks

Will