

Diesel 2: Using generators for async (and back again) - jmintz
http://devblog.bu.mp/generators-and-back-again

======
bsaunder
Does anyone else see a trend in this migration to async style programming?
I've been working on a similar issue for a while now involving a similarity
search engine with nested state machines.

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.

~~~
wmoss
I think the move to async frameworks is primarily precipitated by the fact
that a file handle (which is, essentially, what an async framework holds per
connection) is substantially lighter weight than a thread. When you're talking
about writing a server that can handle thousands of concurrent connections,
threads just become computationally infeasible.

~~~
mhd
That depends a lot on your OS and your threading mechanism. It used to be
pretty bad on Linux for example, but the modern NPTL implementation is much
better. And even then it still doesn't mean that your language has to stick to
a 1:1 threading model.

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.

------
equark
I'm curious if PEP 380 (yield from) would make greenlet less convenient.

<http://www.python.org/dev/peps/pep-0380/>

~~~
jamwt
Yeah, PEP 380 definitely adds some more heft to generators-as-threads,
removing a fair number of the problems I cited in that post.

~~~
equark
Which remain?

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.

------
ericflo
Congratulations, you've just re-invented Eventlet.

~~~
dowskitest
"Now with 100% less crazy socket monkey patching!"

