Skip to content

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

New issue

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

By clicking “No 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? No Sign in to your account

Closed
bcaudell95 opened this issue May 29, 2018 · 1 comment
Closed

Comments

@bcaudell95
Copy link
Contributor

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.

@bcaudell95
Copy link
Contributor Author

Proposed addition: #297

@elprans elprans closed this as completed May 30, 2018
No Sign up for free to join this conversation on GitHub. Already have an account? No Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants