Why not just use the non transactional decorator, 

@ndb.non_transactional
@ndb.non_transactional(allow_existing=True)Decorator to ensure that a 
function runs *outside* a transaction.

*Arguments:*
allow_existingIf True (the default) and if the decorated function is called 
by code in a transaction, the function runs independent of the transaction. 
If False and if the decorated function is called by code in a transaction, 
it raises an exception.
On Wednesday, January 15, 2014 7:34:04 PM UTC+8, Ofri Wolfus wrote:
>
> Hi everyone,
>
> I'm new to python, appengine and this group so please bear with me :)
>
> I have a function that updates a set of entities from different entity 
> groups. The set's size will get bigger than the allowed size of cross-group 
> transactions. The issue is, this function may get called from within an 
> existing transaction.
>
> Now the actual task of the function is not important to the running 
> transaction, and so it should be executed outside of it. What's the best 
> way to accomplish such a thing without restructuring the existing code?
>
> My current solution (which is quite bad IMO) is to run the worker function 
> as a tasklet, then wrap it in an outer function that blocks on the 
> tasklet's result. Something like the following (typed in mail):
>
> @ndb.tasklet
> def worker_func():
>     # do some work
>     raise ndb.Return(True)
>
> def wrapper():
>     assert worker_func() == True
>
> Thanks,
> Ofri
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to