gevent 0.13.1 released

September 23, 2010 Comments off

This is a maintenance release for Python 0.13.0, fixing a number of
issues. Read the changelog for details. Get it from PyPI.

Thanks to Ralf Schmitt who worked with me on this release.

Thanks to the following people who provided patches: David Hain, Teh
Ekik, Dmitry Chechik, Alexey Borzenkov, Antoine Pitrou, Örjan Persson.

Thanks to everyone who reported bugs and participated in the discussion.

Thanks to Leif K-Brooks ( and Spotify who
responded to the sponsorship call and provided funds for gevent

Categories: Announcement

Call for sponsorship

August 10, 2010 Comments off

Is there any interest among the companies to fund gevent development?
I’d love to employ myself as gevent maintainer.

For the past year, gevent was funded from my savings. Currently, I have to do consulting, which takes away time that could be spent on gevent development. I’d rather work on gevent and if you depend on or plan to depend on gevent you probably prefer that I work on it as well.

If you’d like to sponsor gevent, send me an email mentioning how much you’d like to give and we’ll make arrangements. For me as well as for each individual sponsor the whole thing makes more sense if there’s enough money raised to cover a year of full time or at least a year of part time. Thus, before we finalize the agreement, I’ll notify you about the total amount offered and what it covers. If there’s enough for a year, you’ll get a commitment from me not to accept projects/job offers that will interfere with my gevent work for the next year. If there’s not enough, I will tell how many weeks/months I can commit to and it’s up to you whether to proceed.

You can treat me as a contractor: I have a legal entity set up here and will provide invoices and other paperwork necessary so that you can write this off as a business expense. It also does not have to be a one-time payment for the whole year, per quarter or per month payments are perfectly acceptable too.

Funding is more than donating and is closer to commercial support. It cannot change my vision of the project, but you’ll effectively get a developer working on an important part of your software stack while paying only fraction of the cost.

Additionally, here’s what I can do for sponsors:

  • priority help with the issues important to your projects
  • put your logo/link on homepage (for top sponsors)
  • review your gevent-using code (actually I can do it for anyone who asks as I love to see what people are doing with gevent).

If you don’t care about the above but would like to donate to the project, I appreciate that too. Currently, there is no “Donate” button on gevent website, as many PayPal-like services don’t work with my country yet. Nonetheless, there are still ways to do it, send me an email and I’ll reply with the details.

I love working on gevent, it’s the most enjoyable work I’ve ever done and I will remain the maintainer. By funding you can help boosting gevent development and increase its chances to become de-facto standard way for writing network apps in Python.

Categories: Uncategorized

gevent 0.13.0 released

July 14, 2010 1 comment

After two beta versions, the final version of gevent 0.13.0 has been released – you can get it from PyPI.  If you don’t know what gevent is, read the introduction.

The full list of changes is available in the changelog. The major new additions are:

  • gevent.server module to help you implement TCP and SSL servers. Check out the example.
  • gevent.pywsgi — an alternative implementation of WSGI server, based on gevent.server. Unlike libevent-based gevent.wsgi it supports streaming, SSL, keep-alive connections.
  • greenlet’s sharing of exc_info is worked around in this version.
  • gevent.local is now working properly.
  • socket.sendall() function no longer wastes memory by creating substrings of data.
  • fixed reference leaks in core module.

Thanks to Ralf Schmitt, Ted Suzman, Luigi Pugnetti, Randall Leeds, Daniele Varrazzo, Nicholas Piël, Örjan Persson, Uriel Katz.

Categories: Announcement

EuroPython 2010

May 27, 2010 5 comments

UPDATE: Slides and the text of the talk are available for download. Feel free to use for your own presentations under CC3.0.

I’m going to give a talk on gevent at EuroPython on Thursday 22nd July at 11.00am in Birmingham, United Kingdom.

The contents of the talk is not well defined yet but I’d like to cover the following:

  • Coroutine-based approach to network programming and how it solves Python’s concurrency problems.
  • Greenlets: what they do and how they do it. Why they are better than the alternatives – generators, threads.
  • How gevent and eventlet use greenlet to do what they do, the basic principles they operate on.
  • How sockets/events/queues implemented.
  • Real-world applications using gevent; future development plans.

If you have any suggestions regarding the contents of the talk, please post a comment or email me.

Categories: Advocacy Tags:

Google Summer of Code

March 16, 2010 Comments off

Are you a student? Want to contribute to an Open Source project and get paid for that? Apply to Google Summer of Code 2010 to work on gevent.

The Stackless Python’s ideas page for GSoC 2010 includes a gevent-related project.

The proposed idea is to enhance gevent’s core to

  1. support Stackless Python in addition to greenlet
  2. support non-libevent event loops

Stackless Python is an enhanced version of Python with microthreads built-in as well as other interesting features, like microthread pickling and thread-safe channels. The core function is similar to greenlet, which is a switching functionality from Stackless packaged as CPython extension. Other features of Stackless are not present in greenlet which is why it is desirable to port gevent to Stackless.

There are open source implementations of synchronous I/O for Stackless but they are not as comprehensive as gevent’s, which implements a compatible subset of the standard library and provides a way to patch the blocking functions in place.

Successfully undertaking this project would require deep understanding of Stackless API and gevent internals as well as having a good sense of design to keep things simple while making them more general.

Read the project description on the stackless website.

Feel free to ask about this project on the gevent mailing list.

Categories: Uncategorized

Comparing gevent to eventlet

February 27, 2010 5 comments

In this post I try to explain why gevent was started and how it is compares to eventlet.

Note: gevent has switched to libev.


Bob Ippolito wrote the first version of Eventlet in 2006 but ceased working on it fairly early. Donovan Preston took over the maintenance, together with other folks at Linden Lab where he worked at the time. I became interested in Eventlet in 2008, when I was looking for simpler ways to write networking software than with state machines and callbacks. Greenlet-based Eventlet was ahead of the other options that existed at the time (Python’s native generators, raw greenlet, Corotwine) in terms of features and easiness of use.

The project I worked on already depended on Twisted, so I started integrating the two libraries together. In the process of doing that I discovered a number of bugs in Eventlet and ended up rewriting most of its core. My branch was accepted as the way forward and finally released in 2009 as Eventlet 0.8.11. By that time Donovan had already left Linden Lab and Ryan Williams became the primary maintainer.

In the summer of 2009, I have started a new project where a networking library was going to be a major component. However, Eventlet did not meet a couple of requirements:

  • I needed it to use libevent’s event loop because I had another library (written in C) that used it and I wanted to integrate them together in a single process. Eventlet at the time did not have a working libevent support.
  • I needed socket module to work perfectly as I planned to use Python libraries implemented on top of it through monkey-patching. At the time Eventlet had a few bugs that could cause a socket operation to hang.

I have spent some time working on the pyevent-based hub. The result was not very compatible with the rest of Eventlet due to the fact that its Hub API is geared towards pure Python event loops. Making it work smoothly would require significant changes in the interface and implementation of every other hub. The socket module bugs were also specific to event loop, so even though I fixed them for pyevent, they were still present in every other hub. Not having time for a major rewrite of Eventlet I started a leaner project.

Gevent started as Eventlet with a few bugs fixed and a few features dropped.

The differences

1. gevent is built on top of libevent

Update: since 1.0, gevent uses libev and c-ares.

Libevent is a popular portable event loop. It runs your app using the fastest mechanism available on your system, such as epoll on Linux, and kqueue on FreeBSD. Unlike Eventlet, which maintains its own event loops in pure Python and has only recently gained epoll support, all of gevent’s event loops have been well-tested in real-world, high-scale environments.

The superior performance is one of the benefits of tight integration with libevent, but not the only one. Other benefits are

  • Signal handling is integrated with the event loop.
  • Other libevent-based libraries can integrate with your app through single event loop.
  • DNS requests are resolved asynchronously rather than via a threadpool of blocking calls.
  • WSGI server is based on the libevent’s built-in HTTP server, making it super fast.

2. gevent’s interface follows the conventions set by the standard library

For example, gevent.event.Event has the same interface and the same semantics as threading.Event and multiprocessing.Event but works across greenlets. Eventlet has Event class too, but it uses its own way of doing things for no good reason.

I’ve used the standard interfaces in gevent unless a brand new interface has an obvious advantage. In some cases, where re-implementing the whole class wasn’t necessary, the conventions on the method names set by the standard library were followed.

Here are some of those conventions:

  • wait() does not raise an exception;
  • get() can raise an exception or return a value;
  • join() is like wait(), but for units of execution.

Having consistent interface improves the speed at which we can read and reason about the code. Learning the API becomes easier as well.

Not being constrained by backward compatibility, gevent fixed all the API quirks that Eventlet had. The quality of the API is recognized by the users and Eventlet maintainers. Portions of gevent that are not specific to libevent are being incorporated into Eventlet.

3. gevent is not eventlet

It does not have all the features that Eventlet has. If you already use Eventlet these are the reasons why you might not be able to switch to gevent:

  • If you depend on eventlet.db_pool; gevent doesn’t have a module like that.
  • If you depend on eventlet.processes; there’s no support for subprocesses in the library yet. Here’s an example how to build it yourself.
  • If you depend on Eventlet’s threadpool; gevent does have one currently. Update: there’s a new gevent.threadpool module.
  • If you run Eventlet on Twisted reactor.
  • If you cannot depend on libevent.

Gevent aims to be a small and stable core everyone can depend upon. It delegates the job to libevent whenever possible and provides convenient abstractions for coroutine-based programming. It’s inspired by Eventlet but it’s not a fork and it features a new API. The implementation is simpler and more stable.

Read why others are choosing gevent and what you might encounter when porting from eventlet to gevent.

Thanks to Marcus Cavanaugh, Brad Clements, Nicholas Piël, Andrey Popp and Bob Van Zant for reading drafts of this.

Japanese Translation

Categories: Advocacy Tags: , , ,

gevent 0.12.1 released

February 26, 2010 Comments off

Update 2/Mar: Version 0.12.2 is released.

This release improves compatibility of gevent.socket with the standard socket a little bit more and fixes some of the installation issues that people reported on the mailing list.

Read the full changelog and download the package.

Thank you for participating in the discussion, reporting the problems and suggesting the remedies!

Categories: Announcement Tags: