Poll Without Pain.

The performance of nonblocking I/O meets the convenience of coroutines. Packed with a bunch of useful protocols and a first-class toolkit for concurrency, diesel is the best way to write network applications in Python.

Try It (requires RFC 6455 WebSockets):

from diesel.web import DieselFlask
from diesel.util.queue import Fanout
from diesel import first

app = DieselFlask(__name__)
posts = deque([], 5)
router = Fanout()

def clean_msg(msg):
    return {
        'type': 'message', 
        'data': {'nick': 
            cgi.escape(msg['data']['nick'].strip()),
        'message': 
            cgi.escape(msg['data']['message'].strip())} 
        }

@app.route('/feed/ws')
@app.websocket
def handle_ws(addr, inq, outq):
    for msg in posts:
        outq.put(msg)
    with router.sub() as group:
        while True:
            ev, val = first(waits=[inq, group])
            if ev == group:
                outq.put(val)
            else:
                msg = clean_msg(val)
                posts.append(msg)
                router.pub(msg)

Scalable

Diesel's core is a tight event loop that uses epoll to deliver nearly flat performance out to 10,000 connections and beyond. Resident memory overhead per socket is as low as 14kB.

Convenient

No more spaghetti callbacks. Diesel's coroutine-based approach makes it so that you can write code in conventional, intuitive, blocking style. No need to make the difficult decision between speed and complexity.

Loaded

Diesel comes with support for HTTP/1.1 client and server, WSGI + Flask, WebSockets, Redis, ZeroMQ, MongoDB, and Riak out of the box. And hey: if we don't have it, writing it is easy and fun.