

Google App Engine Datastore API proposal by GvR - bockris
http://neopythonic.blogspot.com/2011/01/new-app-engine-datastore-api.html

======
krosaen
""" if we squint a little it looks almost like a synchronous call..

you can take a piece of code that was written using synchronous calls, and
mechanically translate it into a tasklet: just decorate your functions with
@tasklets.tasklet and change your synchronous calls from

result = some_function(args)

into

result = yield some_function_async(args) """

I feel like this style of coding (e.g twisted) is stretching python generators
a bit far... are callbacks really that hard to work with? And this is clever
and all, but what happens when you forget the yield call, or when there is an
exception somewhere down the line, how hard will it be to figure out what is
going wrong? I would prefer the work went into better function literals in
python along with a node.js style approach.

That aside, glad to see better asynchronous support coming to app engine,
using:

<http://code.google.com/p/asynctools>

has already been a big help for constructing complex pages that require a few
different queries.

~~~
deno
I personally like the coroutine approach better (greenlets) since your code
looks synchronous without squinting and usually performs well (there are
various optimization in Stackless Python and PyPy has support as well). With
libraries like gevent, and its API inspired by multiprocessing, asynchronous
handling of code blocking on i/o just becomes another option next to using
threads, processes or computing cluster.

Whereas with node.js/twisted (excluding @inlineCallbacks) approach the
implementation detail—that is how do you talk with OS kernel about I/O—becomes
the force shaping how you design your program and your API.

Sure, there's place for callbacks in Python. But as Python programmers, we can
afford to reserve them for where they belong, like handling high-level events
(i.e. observer pattern).

~~~
cdavid
agreed. I had to use twisted this year, and I find the whole approach really
wrong from an API POV. You have to force everything to use twisted-way, and
this impacts a lot the design of the whole app. inlineCallbacks has its issues
as well (it sometimes lead to wrong stack-traces, and you are shit of out luck
trying to understand what's going on then, but maybe that's just an
implementation flaw).

The use of generator has its flaw as well: as pointed already by other, it is
difficult to compose them effectively, making refactoring quite a PITA.

Gevent seems like the best option in python, but I have never used it, so
maybe it has its drawbacks as well.

------
StavrosK
I haven't read the entire documentation/proposal yet, but this seems to be a
very good foray into asynchronous programming for Python programmers. I'll
have to give it more attention later, and not just for the Datastore stuff.

