Skip to content

Allow nested client context #1001

@remko-bw

Description

@remko-bw

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: datastoreIssues related to the googleapis/python-ndb API.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions