Diesel 2: Using generators for async (and back again)
devblog.bu.mp
devblog.bu.mp
I can't quite tell if my perception of this trend is skewed by my current perspective or if there are more people exploring this model of programming. IMHO, some things get much harder to reason about without some good tools.
The main problem with threads is the relative complexity of the programming and debugging model. I don't really see a complete migration from threads to async, I see a migratino from threads to a multitude of models, where async is just one of them.
In my case, I ended up here by trying to dynamically shift where I'm applying the work load in the search space without pruning off an answer.
The advantage of generators as threads is that they work with other Python implementations like Jython and IronPython. It would be nice if whatever Python adopted in the core wasn't still inferior to greenlet based libraries.
Deleted comment
Actually Diesel used to be more like monocle using yields. But the point of the article was that they re-wrote Diesel to use greenlet in Diesel 2. It is a rather different approach. Yes, underneeth they all have a select/poll/epoll event loop but greenlet is a lot cleaner approach for some use cases.
I use eventlet (http://eventlet.net/) which sits on top of greenlet. So far, I am very satisfied with it. I moved to it from Twisted. It felt like moving from Java back to Python.
As of now I still use some of the eventlet-only features like thread pools and subprocess handling. Performance has not been a problem yet as well. I imagine gevent is faster since it sits on top of libevent ...