2
votes

All, I've been using Flask-Socketio extension with PY2.7, but recently migrated to PY3. There's no Gevent support for PY3 (yet), which breaks Flask-Socketio (the flask-socketio author is also waiting for this, see current limitations).

Is there any alternative to implementing websockets on flask running under NGINX/uWSGI with PY3?

So far: I've come across this server/client implementation that uses PY3's asyncio with no gevent requirement, but it's not for flask. Any advice on how to embed this into the current flask server would also be great. More specifically the server implementation there looks like:

start_server = websockets.serve(hello, 'localhost', 8765)

asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()

Not sure how to embed this into the main flask server script, make it work with uWSGI (which also supports websocket, adding to my confusion), etc. Any advice here?

1
Note that the project that you found is a WebSocket implementation. Flask-SocketIO does more than that, Socket.IO is a higher level protocol that can work over WebSocket but also over other transports for browsers that don't have WebSocket. - Miguel
@Miguel, i knew you'd reply (huge fan of you work!). Yes, I am aware of the (flask-)SocketIO higher level functionality vs websocket only. As I mentioned in the question, the issue is that Gevent doesn't work on PY3, so everything that follows fails.. Any insight as to then Gevent (and Flask-Socketio) will be available on PY3? Would be great to return to that superior setup. - GG_Python

1 Answers

5
votes

The last version of flask-socketio has support for PY3. flask-socketio==1.0b1.

You can see it in Miguel's blog.

Miguel's blog