Running Dash app in Gevent

Hey all!
I’m outgrowing the Flask development server for my new Dash project and working on getting it going on a WSGI server. Gunicorn is out since I’m on a Windows machine, so trying to get Gevent working. Here is what I have so far to work with:


app = dash.Dash(__name__)
app.title='Runtime Information'
app.scripts.config.serve_locally=True
app.config['suppress_callback_exceptions'] = True
app.layout= #some stuff

And I’m trying to call it with


from gevent.pywsgi import WSGIServer
from testerApp import app as application
http_server=WSGIServer(('0.0.0.0',80),application)
http_server.serve_forever()

Getting the following traceback:


Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\gevent\pywsgi.py", line 975, in handle_one_response
    self.run_application()
  File "C:\Python27\lib\site-packages\gevent\pywsgi.py", line 922, in run_application
    self.result = self.application(self.environ, self.start_response)
TypeError: 'Dash' object is not callable

Running this from Python 2.7.15 as some of the modules referenced by my program have not been update to Python 3 yet. Can anybody give me some advice on where I’m going wrong?

The wsgi app is the flask instance in the server attribute of Dash. (app.server)

You can use waitress instead of gevent, it works great on windows.

Still confused. So I tried to add application=app.server() to my main application file and tried to import application to start the server with as from testerApp import application but ran into import errors. How would I get the app.server exposed so that I can call it in Gevent?

Open to switching to waitress as well, but looking through the initial info on Waitress I suspect I’d run into similar issues with getting the app name passed in.

I’ve used gevent in applications before with gunicorn: gunicorn app:server --worker-class gevent. I don’t think it works on windows.

Yeah, no luck. I’m messing with waitress right now at Philippe’s recommendation and looks like its pulling up pretty well. Just trying to get TransLogger going for a console log while at the same time keeping my system broadcasting on port 80.

UPDATE: Got it running on Waitress now and is supporting multiple clients trying to access the server (the main issue that forced me away from the dev server). Thanks for everyone’s help!

2 Likes