Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Django + Gevent + SocketIO = Awesome client/server interactions

Project Description

Alternative Django support for Gevent SocketIO, this is based on mrjmad example project.

What is it useful for

SocketIO is an abstraction layer over several methods to maintain a connection between the client and the server otherwise said long-polling this includes websockets.

Checkout what are websockets?.


Add djsocketio to your INSTALLED_APPS in

Create a in an application of your project. django-socketio-alt will discover every that are in applications installed against Django, so becarful with what you do install in production. can start like this:

from socketio.namespace import BaseNamespace
from socketio.mixins import RoomsMixin, BroadcastMixin

class Namespace(BaseNamespace, RoomsMixin, BroadcastMixin):

    def emit_to_me(self, event, *args):
        pkt = dict(

You can specify a namespace name using the name property like so:

class Namespace(BaseNamespace, RoomsMixin, BroadcastMixin):

    name = 'chat'

If you do not, the default is to use the name of the app, for instance if the app is registred as, the namespace’s name will be chat. Connection to this namespace in the client will be done using the following code:

var socket = io.connect('http://localhost:8000/chat');

Now everything you need to know is in Gevent SocketIO documentation and for some copy-paste goodness you can have a look at the example application in example directory.

Happy living!

How to run the example application

To run the example app you will need to install gevent-socketio, if you did not pip install django-socketio-alt already:

$> pip install gevent-socketio

Since the default port for doing websocket is 8000 and the example app use this default you need to run the django project on another port:

$> ./

Then run the SocketIO thread with the following command:

$> ./ runserver_socketio

Open two windows and start the conversation.


Release History

This version
History Node


History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Hash SHA256 Hash Help Version File Type Upload Date
(3.6 kB) Copy SHA256 Hash SHA256
Source Oct 25, 2012

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting