Skip to content
This repository was archived by the owner on Dec 25, 2023. It is now read-only.

@ndb.non_transaction fails to reset global datastore connection #232

Closed
GoogleCodeExporter opened this issue Jun 10, 2015 · 2 comments
Closed

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?

from google.appengine.ext import ndb
from google.appengine.ext import db

class Test(db.Model):
  pass

@ndb.non_transactional
def bystander():
  Test().put()

@ndb.tasklet
def txn():
 bystander()

@ndb.synctasklet
def main():
  yield ndb.transaction_async(txn)

main()


What is the expected output? What do you see instead?

The code should successfully put the Test entity outside the transaction.  
Instead, it crashes with an AttributeError because the Test().put() attempts to 
use a datastore connection with the ndb adapter.


What version of the product are you using? On what operating system?
1.7.3, OS X


Please provide any additional information below.

A workaround is to manually reset the connection with 
datastore._SetConnection(None) as the first line of a non_transactional 
function.  It would probably be better to restore the original datastore 
connection but that's held in a local variable in Context.transaction and not 
accessible.

Original issue reported on code.google.com by pi...@knowlabs.com on 6 Jan 2013 at 12:57

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant