Does ndb.toplevel break transactions?

前端 未结 1 1491
天命终不由人
天命终不由人 2020-12-31 23:50

The following code works as expected and does not trigger the assertion:

@ndb.transactional
@ndb.tasklet
def Foo():
  assert ndb.in_transaction()


        
相关标签:
1条回答
  • 2021-01-01 00:18

    I discovered that the problems is that both create new contexts. transactional creates a context and ensures that all writes that happen inside of it are non-conflicting. toplevel creates a context and ensures that all futures that are created inside of it are resolved.

    As a result, toplevel is clobbering transaction's context. The two just can't be combined in their current implementation.

    0 讨论(0)
提交回复
热议问题