Some of you know that for the last few weeks I have been quietly but steadily working on a significant new release of Flask-SocketIO that will be labeled 1.0, and that is practically a complete rewrite. Given that this is a fairly popular extension, I would like to ask existing users to test it and provide feedback before it is officially released.
What Is Changing?
A lot of things are changing under the covers in 1.0, and inevitably a few things are also changing in the public interface. However, I expect most existing applications will require little or no changes to run on the 1.0 release.
The heavy dependency on gevent has also been removed. In this new version you can choose to use eventlet, gevent or a plain old WSGI web server such as Werkzeug. Out of these three options, eventlet is currently the most complete implementation, with support for the HTTP long-polling and WebSocket transports. The other options only support long-polling at this time.
As a nice side effect of these changes, I can now offer support for Python 3, and since eventlet is very stable on both Python 2 and Python 3, that means that you can use the current Socket.IO client, with the WebSocket transport, on Python 2.7, 3.3 or 3.4.
Here is a more complete list of changes in version 1.0, extracted from the documentation:
- Release 1.0 drops support for Python 2.6, and adds support for Python 3.3, Python 3.4, and pypy.
- The 0.x releases depended on gevent, gevent-socketio and gevent-websocket. In release 1.0 gevent-socketio and gevent-websocket are not used anymore, and gevent is one of three options for backend web server. The other two options are eventlet, and any regular multi-threaded WSGI server, including Flask's development web server.
- The Socket.IO server options have changed in release 1.0. They can be provided in the SocketIO constructor, or in the
run()call. The options provided in these two are merged before they are used.
- The 0.x releases exposed the gevent-socketio connection as
request.namespace. In release 1.0 this is not available anymore. The request object defines
request.namespaceas the name of the namespace being handled, and adds
request.sid, defined as the unique session ID for the client connection, and
request.event, which contains the event name and arguments.
- To get the list of rooms a client was in the 0.x release required the application to use a private structure of gevent-socketio, with the expression
request.namespace.rooms. This is not available in release 1.0, which includes a proper
- The recommended "trick" to send a message to an individual client was to put each client in a separate room, then address messages to the desired room. This was formalized in release 1.0, where clients are assigned a room automatically when they connect.
'connect'event for the global namespace did not fire on releases prior to 1.0, due to a problem in gevent-socketio. This has been fixed and now this event fires as expected.
- Support for client-side callbacks was introduced in release 1.0.
If you use Flask-SocketIO, I would appreciate it if you try your application with my current working 1.0 release and provide feedback. I'm particularly interested to find out if you had to make lots of changes to your application to make it work with this version. I made every effort to minimize the changes to the public API, but I did have to make some changes.
How To Install Flask-SocketIO 1.0
I have pushed my current 1.0 version to PyPI as release 1.0a1 (Edit: current version is 1.0b1). Because it is a development version, you have to explicitly request this version to get it:
$ pip install flask-socketio==1.0b1
Or if you are upgrading an existing virtualenv:
$ pip install --upgrade flask-socketio==1.0b1
You can find the example application here: https://github.com/miguelgrinberg/Flask-SocketIO/tree/v1.0/example
If you prefer to install from GitHub, I have pushed this version to the official repository under branch v1.0.
How To Provide Feedback
You can post your comments below, or find me on Twitter or elsewhere. Just contact me in the way that is easier for you.
I appreciate your feedback!