Eventlet

Eventlet is a concurrent networking library for Python that allows you to change how you run your code, not how you write it.

  • It uses epoll or kqueue or libevent for highly scalable non-blocking I/O.
  • Coroutines ensure that the developer uses a blocking style of programming that is similar to threading, but provide the benefits of non-blocking I/O.
  • The event dispatch is implicit, which means you can easily use Eventlet from the Python interpreter, or as a small part of a larger application.

It's easy to get started using Eventlet, and easy to convert existing applications to use it. Start off by looking at examples, common design patterns, and the list of the basic API primitives.

License: MIT.

API Documentation

Installation

To install Eventlet, simply:

pip install eventlet

Alternately, you can download the source archive:

Discussion

Development

Both repositories are equal and kept in sync. You can use whichever you fancy for downloading, forking, reporting issues and submitting pull requests.

Mercurial repository used to be the main one, but most of the contribution and discussions happen on Github nowadays.

Pull request policy

  • Test is required
  • One commit is strongly preferred, except for very big changes
  • Commit message should follow the following formula:
    subsystem: description of why the change is useful
    
    optional details or links to related issues or websites
    
    The why part is very important. Diff already says what you have done. But nobody knows why.
  • Feel free to append yourself into AUTHORS file, sections Thanks To or Contributors.

If you don't like these rules, raw patches are more than welcome!

Bugs

Please be sure to report bugs as effectively as possible, to ensure that we understand and act on them quickly.

You may report bugs via:

  1. Github
  2. Bitbucket (no registration is required)
  3. Email eventletdev@lists.secondlife.com

Web Crawler ExampleΒΆ

This is a simple web “crawler” that fetches a bunch of urls using a coroutine pool. It has as much concurrency (i.e. pages being fetched simultaneously) as coroutines in the pool.

import eventlet
from eventlet.green import urllib2


urls = [
    "http://www.google.com/intl/en_ALL/images/logo.gif",
    "https://wiki.secondlife.com/w/images/secondlife.jpg",
    "http://us.i1.yimg.com/us.yimg.com/i/ww/beta/y3.gif",
]


def fetch(url):
    return urllib2.urlopen(url).read()


pool = eventlet.GreenPool()

for body in pool.imap(fetch, urls):
    print("got body", len(body))

Stats

Travis build

Links