-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Push batch / transaction onto a thread-local stack inside 'with'. #518
Push batch / transaction onto a thread-local stack inside 'with'. #518
Conversation
if exc_type is None: | ||
self.commit() | ||
try: | ||
if exc_type is None: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Add explicit test of using the stack.
Nesting batches "works": it just "suspends" the outer batch until the inner one exits. It does mean that the "inner" changes will be sent to the back-end before the "outer" ones, but folks using The problem I was trying to solve was to make discovery of any current batch / transaction straightforward, even if the application does weird stuff like nesting (maybe accidentally). If nesting is not a desirable feature, then we can close this PR and do something like your suggestion instead. |
Motivating example:
which will all Just Work(TM) even in the face of nesting. |
I keep confusing myself. The key focus here is that That said, I still think the maintenance cost of a stack is not worth the minimal gain in functionality (which many users may never see). Users motivated enough to want nested / conditional transactions can accomplish the same thing with the API provided by I'm torn between "it already works as intended" and "let's not add code that we don't need to". |
That's actually why I made |
It's not us touching it that worries me, it's bugs from exotic usage in the wild that we don't / won't have bandwidth or desire to deal with. For example, what if someone calls a method that uses a context manager under the hood, and they expect with Transaction() as txn:
funky_save() to save in As I said, I don't think the burden of a larger surface area justifies the small set of use cases that this enables syntactically. I'm much more comfortable
|
I don't see how your example is problematic: if @silvolu Do the other mappings support nesting? |
I'm not saying the functionality is damaging, I'm saying the maintenance burden on us is not worth it. |
Hmm, the maintenance / explainability of the consistent / nested one seems easier to me than maintaining / explaining the "Highlander" case. |
I suppose you're right. I'm probably just being paranoid. Let's hope it doesn't bite us. |
LGTM |
…ext_mgr Push batch / transaction onto a thread-local stack inside 'with'.
Also: - Changing api.get() back to accept only `keys` and returns only a list (a lot of headache for not much gain). - Factored out behavior to extract shared dataset_id from a set of keys into _get_dataset_id_from_keys(). - Updated docstrings and other tests that rely on changed / removed methods. See googleapis#518 for some context.
Also: - Changing api.get() back to accept only `keys` and returns only a list (a lot of headache for not much gain). - Factored out behavior to extract shared dataset_id from a set of keys into _get_dataset_id_from_keys(). - Updated docstrings and other tests that rely on changed / removed methods. See googleapis#518 for some context.
Also: - Changing api.get() back to accept only `keys` and returns only a list (a lot of headache for not much gain). - Factored out behavior to extract shared dataset_id from a set of keys into _get_dataset_id_from_keys(). - Updated docstrings and other tests that rely on changed / removed methods. See googleapis#518 for some context.
* chore: Prepare for mono repository migration * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Source-Link: googleapis/synthtool@453a5d9 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:81ed5ecdfc7cac5b699ba4537376f3563f6f04122c4ec9e735d3b3dc1d43dd32
…p/templates/python_library/.kokoro (#518) Source-Link: https://github.com/googleapis/synthtool/commit/bb171351c3946d3c3c32e60f5f18cee8c464ec51 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:f62c53736eccb0c4934a3ea9316e0d57696bb49c1a7c86c726e9bb8a2f87dadf
Source-Link: https://github.com/googleapis/synthtool/commit/352b9d4c068ce7c05908172af128b294073bf53c Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:3e3800bb100af5d7f9e810d48212b37812c1856d20ffeafb99ebe66461b61fc7
…pprove] (#518) Source-Link: https://github.com/googleapis/synthtool/commit/e3a1277ac35fc88c09db1930533e24292b132ced Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:452901c74a22f9b9a3bd02bce780b8e8805c97270d424684bff809ce5be8c2a2
Source-Link: googleapis/synthtool@7197a00 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:c43f1d918bcf817d337aa29ff833439494a158a0831508fda4ec75dc4c0d0320 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
Prep. for #514.