I have a POST
method which calls a few tasklets. These tasklets do have yields in them, and I do have some x.put_async()
in my code. So I don't want it to return before all the async stuff is done. So I decorated all my tasklets, which are just small functions with @ndb.tasklet
. Also, on top of my POST
method, I have:
@ndb.toplevel
def post(self):
However, in the documentation it states:
But if a handler method uses yield, that method still needs to be wrapped in another decorator, @ndb.synctasklet; otherwise, it will stop executing at the yield and not finish.
Indeed my method has a yield. It's already wrapped in @ndb.tasklet. Do I replace this with @ndb.synctasklet or do I use both (if so how would I use both)?
Also, see this thread which has some relevance. I too noticed an issue where my request would return without any output, but is un-reproducible. It happens every 15 minutes or so of constant use. I had app = ndb.toplevel(webapp2.WSGIApplication([..])
only, but now I've added @ndb.toplevel
to the main POST
methods, but the issue still persists.
Should I put @ndb.tasklet
on top of methods that have just put_async()
's too? (Should I put it on top of every method just to be safe? What are the downsides to this?)