Skip to content

Expose method on Connection object to determine if inside transaction #296

Description

@bcaudell95

Inside code using Connection objects to issue queries, it would be nice to assert that the Connection is inside a transaction. This allows production code using the library to nicely separate the code handling the fetching of Connections from the code issuing queries while still allowing the latter to make assertions about the context it's in.

Looking at the code, there is a member variable _top_xact which is None if not inside a transaction block, and which is set to the Transaction object otherwise. Thus, it appears to me that simply checking the value of this variable is sufficient for this method. Correct me if I'm missing anything.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions