I've started working a lot with Flask SocketIO in Python with Eventlet and are looking for a solution to handle concurrent requests/threading. I've seen that it is possible with gevent, but how can I do it if I use eventlet?
The eventlet web server supports concurrency through greenlets, same as gevent. No need for you to do anything, concurrency is always enabled.
You could use gunicorn
or its analogs to launch the app in production mode with several workers. As said here :
gunicorn --worker-class eventlet -w 5 module:app
Where the number after -w
is the number of workers, module
is your flask-socketio server module, and app
is the flask app ( app = flask.Flask(__name__)
). Each worker is a process busy with handling incoming requests, so you will have concurrency. If the tasks your app does take significant time, the worker doing that task will be irresponsive while doing it.
Note: if you launch your app this way, the if __name__ == '__main__':
part will be ignored, it seems that your module will be imported. And you don't need to call app.run
yourself in the module in this case
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.