Safe to call ndb tasklet get_result() in a tasklet?

35 views
Skip to first unread message

ckhan

unread,
Nov 29, 2012, 8:30:36 PM11/29/12
to google-a...@googlegroups.com
From the NDB async docs: 

Furthermore, instead of using acct = key.get() or acct = key.get_async().get_result(), the function should useacct = yield key.get_async(). This yield tells NDB that this is a good place to suspend this tasklet and let other tasklets run.

Re the second example: get_async().get_result()
I believe I understand why yield works here, and how it lets the system return to event loop.

But is calling get_result() just inefficient, or is it actually dangerous, because it is effectively a synchronous call in the tasklet, and I'm now vulnerable to hard-to-diagnose stack overflows when the event loop is recursively invoked (http://code.google.com/p/appengine-ndb-experiment/issues/detail?id=167)?

Plan to re-write to use yield anyway - just trying to better understand the tasklet/async/eventloop system.
Thanks for any insight.
-ck

Reply all
Reply to author
Forward
0 new messages