Kaan Soral
Kaan Soral

Reputation: 1645

What is the prettiest way to make deferred wait for async ndb calls?

deferred.defer(f,e)

function f(e):
  e.put_async()

Changes to e are discarded in the SDK and presumably on production too. One obvious way to solve the problem is to store all rpc's and get_result() them, but this is not pretty.

Is there a way to make this function ndb-compatible?

This function is used in multiple parts of the code, normal requests are @ndb.toplevel, so there is no problem for them.

Upvotes: 1

Views: 327

Answers (1)

Greg
Greg

Reputation: 10360

The function that you defer can't be an @ndb.toplevel, but you can have that call a function that is:

def f(e):
  g(e)

@ndb.toplevel
def g(e):
  e.put_async()

Upvotes: 2

Related Questions