Search code examples
uwsgigeventflask-socketio

Why does flask-socketio stay http-polling under uWSGI+gevent if threading is enabled


Using flask-socketio successfully under uWSGI using gevent with threading DISABLED. You can see the socket connection change to a true websocket connection.

For other reasons in our app, we want to enable threads (calling long-duration native library calls that block, and gevent can't help). Once we do this, the websocket connection never truly changes to a real websocket connection - it stays in an http polling mode.

Is this this just the nature of the beast? Something about threading is incompatible with flask-socketIO, or should I be able to get this to work?


Solution

  • Threading and gevent are essentially incompatible, you have to pick one or the other. But websocket is only supported under gevent, so the choice is sadly already made.

    As a side note, I may be wrong, but I suspect the websocket connection is not the only problem when you introduced threads on top of gevent. I think you will also see connection errors and reconnections on long polling due to this.