Tulip/asyncio at PyConES

It has been an intense weekend. I’ve been in Madrid for PyConES, and all I have to say is that it was amazing! Lots of great talks, old friends and new ones, I had a blast!

I gave a presentation on Tulip/asyncio in Spanish, but since code kind of speaks for itself, you may find some value in my slides here:

This is a hot topic these days, and proof of that is the fact that mine wasn’t the only Tulip/asyncio talk at PyConES. I had the pleasure to work with I├▒aki Galarza, who also gave a presentation about Tulip so that our talks would complement each other’s. You can find his slides here:

I really hope I can make it next year, and you should too!



Evergreen: cooperative multitasking and i/o for Python

I’ve been working on-and-off on this project for almost a year during my free time, and after meditating about it I thought: “fuck it, ship it”. Allow me to introduce Evergreen: cooperative multitasking and i/o for Python.

“So, another framework?” I hear you say. Yes, it’s another async framework. But it’s my async framework. I’ve used a number of frameworks for┬ádeveloping┬áservers in Python such as Twisted, Tornado, Eventlet, Gevent and lately Tulip and all of them have great and not so great things, so I decided to blend the ideas I gathered from all of them, add some opinionated┬ádecisions, some Stackless flavour and Evergreen was the result.


Evergreeen is a framework which allows developers to write synchronous looking code which is executed asynchronously in a cooperative manner. Evergreen presents an API which looks like the one you would use to write concurrent programs using threads or futures from the Python standard library. The facilities provided by Evergreen are however cooperative, that is, while a task is busy waiting for some i/o other tasks will have their chance to run.

“Show me the code!” I hear you say. Sure, it’s up here on GitHub, released under the MIT license. Since the usual example is a web crawler, here you have one.

Did I mention it supports Python 2 and 3?

“Is it production ready?” I hear you say. It’s still on a very early stage, but I believe the foundation is solid. However, the APIs provided by Evergreen may change a bit until I feel confortable with them. All feedback is welcome, so if you give it a try do let me know!

I’d like to thank all authors of similar libraries for releasing their work as Open Source which I could look into and learn from.

I hope Evergreen can help you solve some problems and you enjoy using it as much as I do developing it.



Rose: a PEP-3156 compatible event loop based on pyuv

For those who don’t know, PEP 3156┬áis a proposal for asynchronous I/O in Python, starting with Python 3.3. Until now each framework (Twisted, Tornado, …) has defined it’s own interface for defining protocols and transports. This makes very difficult if not impossible to reuse a protocol implementation across frameworks. PEP 3156 tries to fix that, among other things.

The reference implementation is called Tulip and can be found here. It’s a fast moving target, but it already contains working event loops for Windows and Unix systems. It uses pollers available in the select module for the Unix side, and a C module wrapping Windows IOCP┬áfunctionality┬áfor Windows.

I was really excited to see this come through, so I started playing with it by implementing a pyuv based event loop. I called that it rose. It was a lot easier to implement than expected and it currently passes the entire test suite ­čÖé

Code can be found on GitHub.

Here is a quick example, the usual echo server, using rose and tulip:

Come and join the discussion in the python-ideas mailing list!


How do event loops work in Python?

I had the pleasure to give a presentation at the first ever Python Devroom at FOSDEM. I talked about how event loops work internally and how pyuv can help by abstracting a lot of the problems with a pretty simple to use API. I also introduced rose, a pyuv based PEP-3156 event loop implementation, but I’ll write a followup post on that ­čÖé

Thanks a lot to everyone who attended the talk, and for those who couldn’t here are the slides!