miguelgrinberg / Flask-SocketIO

Socket.IO integration for Flask applications.
MIT License
5.35k stars 889 forks source link

Gunicorn reload option doesn't work with flask-socketIO #2089

Open Andrew-Rand opened 1 week ago

Andrew-Rand commented 1 week ago

Hello!

I try to use flask-socketio with gunicorn and at it works well. But when i try to use reload mod for debbuging, autoreload doesn't work on code changes. It happens only if i run socketio. I use eventlet as you recommend.

Example:

from flask import Flask from flask_socketio import SocketIO

app = Flask('app')

socketio = SocketIO()

socketio.init_app( app, message_queue='redis://redis:6379/0', logger=False, engineio_logger=False, cors_allowed_origins='*', async_mode='eventlet', ) socketio.run(app, port=5005)

run in terminal

gunicorn --worker-class eventlet -w 6 main:app --reload

My dependecies:

Python 3.11.9

flask==1.0.3 jinja2==2.11.2 packaging==21.3 gunicorn==22.0.0 markupsafe==1.1.1 itsdangerous==1.1.0 six==1.15.0 dnspython==2.1.0 eventlet==0.33.0 greenlet==2.0.2 flask-socketio==5.3.7 werkzeug==0.16.1 flask-redis==0.4.0

Thank you!

miguelgrinberg commented 1 week ago

I have no control over when Gunicorn decides to reload. The Flask reloader is supported and to my knowledge works fine.

I use eventlet as you recommend.

I haven't recommended eventlet in the last several years. In fact eventlet is a bad choice to use because it is a dying project. See https://eventlet.readthedocs.io/en/latest/ for details.