Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow nested client context #1001

Open
remko-bw opened this issue Aug 7, 2024 · 0 comments
Open

Allow nested client context #1001

remko-bw opened this issue Aug 7, 2024 · 0 comments
Labels
api: datastore Issues related to the googleapis/python-ndb API.

Comments

@remko-bw
Copy link

remko-bw commented Aug 7, 2024

When you call client.context() after you have already used a context, you get a fatal error:

Context is already created for this thread.

However, AFAICT, nested contexts are supported by NDB internally, and this seems to be just a check in client.context() that prevents this. Is there a reason for preventing nested contexts? If not, can this check be removed?

I want to use a client connected to a specific database through my app, but for some very local (deeply nested) operations, i want to connect to a different database for my data accesses. I would have a second client, and use a client.context() on this client before doing these operations, but this doesn't seem to be possible. I assume that I can create and use the Context object myself, but I wanted to understand why NDB prohibits this in the client.

@product-auto-label product-auto-label bot added the api: datastore Issues related to the googleapis/python-ndb API. label Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the googleapis/python-ndb API.
Projects
None yet
Development

No branches or pull requests

1 participant