@ndb.synctasklet
def log_usage(self):
@ndb.transactional_tasklet(xg=True)
def _txn():
# some other stuff happens here, but trying to make this example as simple as possible.
yield Log.insert_document_log_async()
yield _txn()
class Log(ndb.Expando):
@classmethod
@ndb.tasklet
def insert_document_log_async(cls):log = cls()
logging.debug("insert document log in transaction: {}".format(ndb.in_transaction()))
yield log.put_async()
@ndb.synctasklet
def _post_put_hook(self, future):@ndb.synctasklet
def _callback_on_commit():key = future.get_result()yield SqlTaskHelper.enqueue_syncronise_sql_model_async(key)
logging.debug("_post_put_hook In transaction: {}".format(ndb.in_transaction()))
ndb.get_context().call_on_commit(lambda: _callback_on_commit())
--
You received this message because you are subscribed to a topic in the Google Groups "Google App Engine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-appengine/Zx5LN3AVjUA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-appengi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/2a78bb0e-79a4-4e4e-97c4-1dd76a2fb6e3%40googlegroups.com.
Thanks Diogo,But that’s why we check get_result for the key. If the get_result failed for the the future, the key wouldn’t be returned would it?
To unsubscribe from this group and all its topics, send an email to google-appengine+unsubscribe@googlegroups.com.
To unsubscribe from this group and all its topics, send an email to google-a...@googlegroups.com.
Hello Rob,
It seems that you have a technical question regarding code. Google Groups are meant to discuss and share opinions about Google Platform and products. Please post your scenario on Stackoverflow, where you may receive advice from our programming community.