18 comments

[ 2.8 ms ] story [ 59.0 ms ] thread
I've been using gevent-socketio for websockets with Flask. I'm new to python. Can someone tell me why I'd want to use this over gevent-socketio?
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.
Have you put this into production? Are you using Gunicorn on the server?
A few questions, does this work with Python 3.3?

Also, how is it better than Tornado web sockets?

Python 3 compatibility was my first question also.

Unfortunately this relies on gevent and gevent does not work on py3.

Why does something have to be better to be useful?
This looks like a thin wrapper over gevent-websocket. The code is slightly longer than the README: https://github.com/kennethreitz/flask-sockets/blob/master/fl...

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.

On top of that, tornado has built-in support for multiprocessing, so you can forego gunicorn as well: https://gist.github.com/jholster/2290574
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.
Yep, totally get it. Just want to make sure people know about tornado as an option for greenfield projects.
I was kind of hoping this would be some sort of power socket shaped like a pocket flask.
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.

> (And in practice I don't think you would want to deploy on anything besides Gunicorn.)

(You should definitely have a look at uWSGI.)

I have been running uWSGI for many years, I only recently made the switch to Gunicorn for the async gevent/websockets support.

(The last time I looked, which was a few months ago anyway, uWSGI support for gevent/websockets wasn't very robust.)