Why Gevent On A Flask App With Apache + Mod_wsgi Is Raising Notimplementederror?
Solution 1:
It seems like i found the solution myself. The following directive solved my issue:
WSGIApplicationGroup %{GLOBAL}
The idea comes from another answer where it is suggested to set WSGIApplicationGroup to GLOBAL to solve a problem with a WSGI process that keep crashing. From WSGI documentation:
To force a specific WSGI application to be run within the very first Python sub interpreter created when Python is initialised, the WSGIApplicationGroup directive should be used and the group set to '%{GLOBAL}'.
Cannot fully understand why this directive solve my issue but it does. I will be more than happy if someone is able to explain this to me in plain English ;-)
Solution 2:
Try replacing monkey.patch_all()
with monkey.patch_all(thread=False)
. If it's really the threading module which is causing the trouble when patched, this should solve it. request
does not use threading.
Solution 3:
I posted below answer on https://serverfault.com/a/869625/355861
apache mod_wsgi is not currently compatible with gevent. For AWS elastic beanstalk with Apache, I used async_mode="threading" for Flask and it works well. Note, threading has less performance than gevent. https://flask-socketio.readthedocs.io/en/latest/#deployment
app = Flask(__name__,static_folder='static')
socketio = SocketIO(app, async_mode="threading")
Note that Flask can run standalone with gevent.
app = Flask(__name__,static_folder='static')
socketio = SocketIO(app, async_mode="gevent")
if__name__== '__main__':
HOST = '127.0.0.1'
PORT = 5055
socketio.run(app, port=PORT, host=HOST)
However, you really want an HTTP server in front of it such as Gunicorn.
Post a Comment for "Why Gevent On A Flask App With Apache + Mod_wsgi Is Raising Notimplementederror?"