Maybe if you only want WebSocket, and you're already using Flask, and you want to give up events and roll out your messaging protocol. Sounds like a lot of work.
Not to discredit the attempt to make gevent-websocket more accessible, but there's nothing really new here. Here's an example of using gevent-websocket with flask without this library:
https://gist.github.com/lrvick/1185629
When used in conjunction with Gunicorn, this setup gets significantly more complicated, involving middlewares and monkeypatches. That's why I wrote the module :)
This also doesn't require the use of Gevent, like using gevent-websockets directly does. Anything that inserts `wsgi.websocket` into the WSGI environ will suffice here.
Tornado is an excellent choice for websockets, but someone shouldn't have to switch web frameworks just to support them. This works well for people who like working with Flask and have existing applications that they want to add websocket support to.
Flask users will be grateful for support of web-sockets, because beginner in python can use flask & now flask-sockets too for building small but useful projects.
Thanks Reitz for this.
Thanks for this. A few months ago I looked into getting gevent-socketio up and running to do real-time messaging between a Flask app and an iOS app. gevent-socketio provides event handling and a messaging protocol on top of websockets that I thought would be useful.
However, based on my testing, in its current state it's nowhere near ready for production. There are some serious bugs relating to memory leaks, improperly closing stale sockets, and deployment on Gunicorn with # workers > 1 is not currently possible. (And in practice I don't think you would want to deploy on anything besides Gunicorn.) The project also seems to be somewhat inactive, there are a lot of open critical issues and there hasn't been any real activity in the last 6 months or so.
At this point I am considering removing the library and using a straight websocket implementation with a simpler protocol instead.
18 comments
[ 2.8 ms ] story [ 59.0 ms ] threadAlso, how is it better than Tornado web sockets?
Unfortunately this relies on gevent and gevent does not work on py3.
https://github.com/surfly/gevent/issues/38
You can check Python 3 support for major packages at: https://python3wos.appspot.com
Not to discredit the attempt to make gevent-websocket more accessible, but there's nothing really new here. Here's an example of using gevent-websocket with flask without this library: https://gist.github.com/lrvick/1185629
This also doesn't require the use of Gevent, like using gevent-websockets directly does. Anything that inserts `wsgi.websocket` into the WSGI environ will suffice here.
http://www.tornadoweb.org/en/stable/websocket.html
However, based on my testing, in its current state it's nowhere near ready for production. There are some serious bugs relating to memory leaks, improperly closing stale sockets, and deployment on Gunicorn with # workers > 1 is not currently possible. (And in practice I don't think you would want to deploy on anything besides Gunicorn.) The project also seems to be somewhat inactive, there are a lot of open critical issues and there hasn't been any real activity in the last 6 months or so.
At this point I am considering removing the library and using a straight websocket implementation with a simpler protocol instead.
(You should definitely have a look at uWSGI.)
(The last time I looked, which was a few months ago anyway, uWSGI support for gevent/websockets wasn't very robust.)