News for hackers. Stuff that matters.
Re:Monocle - An async programming framework with a blocking ... by aliguori on Tuesday July 27, 2010 @05:32PM (#1552807)
Right. You have to be very careful to always yield to another function that uses yield. It can become very hairy with deep call chains.

The limitation is that Python has to be statically prove that a function is really a generator for yield to work and they do this by forcing there to be a yield in the actual function.

Re:Monocle - An async programming framework with a blocking ... by jamwt on Tuesday July 27, 2010 @06:16PM (#1552926)
Yep, this was a big part of why I eventually abandoned generators in diesel in favor of a greenlet-based approach.

http://github.com/jamwt/diesel/commit/2fc64f9d50bc6f9a5cfff0...

I'd worked my way through all the problems having to do with simulating a generator-based "stack" and it was not pretty--exception handling in particular with these "fake stacks" was hard to make behave the usual pythonic way.

I wasn't eager to give up on a generators, but I had to eventually concede that the practical quality of the project was more important than the founding idea.

Everything has been faster, easier to program, and more stable since giving up on generators and moving to the greenlet library. At bump, we just launched version 2.0 of our app, running our backends 100% on diesel2/greenlets:

http://mashable.com/2010/07/26/bump-2-0/