Online Mind Mapping and Brainstorming

Create your own awesome maps

Online Mind Mapping and Brainstorming

Even on the go

with our free apps for iPhone, iPad and Android

Get Started

Already have an account? Log In

Async networking in Python, Uriel Katz by Mind Map: Async networking in Python, Uriel Katz
5.0 stars - 1 reviews range from 0 to 5

Async networking in Python, Uriel Katz

Greenlets in pure python

Uses libev for the event loop, libeio for file IO


used by

has some problems, but Uriel says it's good for production

Uriel's favorite

will be used in their next release

gives you sync API on top of async networks

pluggable event loop

written in Python

thread pool built0in

monkey patching on steroids

DB API using threads

has a DBAPI 2.0 compatible MySQL driver

Doesn't seem active in production

replaced Twisted

twisted, commonly used for building high-performance server in Python, reactor pattern & deferred (aka Future), very mature & adopted, hard to learn, uses callbacks with defferes which results in terrible code


R&D manager at Binfire

Python for infra



gevent, concurrence, twisted, eventlet (& node.js)

Async networking

handling many concurrent users

basic idea

get a notif when a socket is ready for some IO operation & continue with other stuff until IO is available

like callbacks in javascript

using 1 thread like this: blocking calls block all requests

in operating systems

file descriptors, in Linux, epoll

only good for very heavy computation



abstracts the different OS implementations

fork of eventlet


reactor based with callbacks

thinks it's very difficult to work with


libevent based with Greenlets/stackless

like threads, but not primitive

from Hyves (the dutch facebook)


libevent/epoll based with greenlets from Linden Labs (SecondLife)


libevent based with greenlets

like Erlang's actors

use channels to communicate between tasklets


thread safe

quite slow

Websockets support

slightly slower than Gevent

Bug & messy compared to Gevent

Something extra - Node.js

Vitaly: "Erlang for poors"

Evented IO on top of Google's V8 JS engine

compiles JS to assembler, JIT

though main time is on IO not processing

has async file IO

very hard to do

in linux, no real async file IO

let's you write high-performance servers in JavaScirpt

parser written in Rebel


Comet-like chat examples (no-polling)


/, just serve index


/wait, returns when new data exists

all users call the wait method, but the server doesn't need threads serving all waiting clients

See examples the slides







Largest pitfall

Each greenlet must give control to next greenlets

If 1 is blocking, all will be blocked

Can't escape this - a price we need to pay

Uriel's experience with Gevent

patches to pywsgi


waitany function

stuff done in work

streaming proxy to Rackkspace cloud files, libevent doesn't support streaming, streaming zip, parts, without files, 500 concurrent connections with 45MB of memory, like the url's in S3 specific for user

comet message bus

real-time drawing like Google drawing

what is this???

Doesn't have a standard socke implementation & no monkey-patchng support

New node

Новый узел

Новый узел