[Python-ideas] Async context managers and iterators with tulip

Guido van Rossum guido at python.org
Sat Dec 22 17:03:29 CET 2012


On Sat, Dec 22, 2012 at 4:57 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> On Sat, Dec 22, 2012 at 10:26 PM, Laurens Van Houtven <_ at lvh.cc> wrote:
>> I can't quite tell by the wording if you consider
>> two-languages-for-the-price-of-one a good thing or a bad thing; but I can
>> tell you that at least in Twisted, explicit suspension points have been a
>> definite boon :) While it may lead to issues in some things (e.g. new users
>> using blocking urllib calls in a callback), I find the net result much
>> easier to read and reason about.
>
> On balance, I consider it better than offering only greenlet-style
> implicit switching (which is effectively equivalent to preemptive
> threading, since any function call or operator may suspend the task).
> I'm also a lot happier about it since realising that the model of
> emitting futures and using "yield from f" where synchronous code would
> use "f.result()" helps unify the two worlds.

I wouldn't go so far as to call that unifying, but it definitely helps
people transition. Still, from experience with introducing NDB's async
in some internal App Engine software, it takes some getting used to
even for the best of developers. But it is worth it.

-- 
--Guido van Rossum (python.org/~guido)



More information about the Python-ideas mailing list