The following code works as expected and does not trigger the assertion:
@ndb.transactional
@ndb.tasklet
def Foo():
assert ndb.in_transaction()
The following code breaks, triggering the assertion:
@ndb.transactional
@ndb.toplevel
def Foo():
assert ndb.in_transaction()
I tried replacing the decorator with an ndb.transaction call or an ndb.transaction_async call, but neither worked.
Is there a bug with ndb.toplevel and transactions?
ndb.toplevel
is to set a fresh default context. So I don't understand the use ofndb.transactional(ndb.toplevel(Foo()))
. Why need you to create a transaction AND then delete it's context? – Floridafloridia