| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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 Batch aren't supposed to care about that, right? 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. |
Sorry, something went wrong.
|
Motivating example: from gcloud.datastore.batch import _BATCHES, Batch
def put(*entities):
current = _BATCHES.top
in_batch = current is not None
if not in_batch:
current = Batch()
for entity in entities:
current.put(entity)
if not in_batch:
current.commit()
def delete(*keys):
current = _BATCHES.top
in_batch = current is not None
if not in_batch:
current = Batch()
for key in keys:
current.delete(key)
if not in_batch:
current.commit()
which will all Just Work(TM) even in the face of nesting. |
Sorry, something went wrong.
|
I keep confusing myself. The key focus here is that with must be called and when __exit__ occurs the stack is happy. Hence there is no such thing as interleaving. 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 byBatch. The complexity becomes their burden, not ours. I'm torn between "it already works as intended" and "let's not add code that we don't need to". |
Sorry, something went wrong.
|
That's actually why I made _BATCHES private (only capitalized as a sop to pylint :): Nobody but us chickens should touch it. |
Sorry, something went wrong.
|
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 txn when instead it spawns a new transaction and doesn't save there. 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
|
Sorry, something went wrong.
|
I don't see how your example is problematic: if funky_save manages its own transaction, separate from the surrounding one, their changes will still be saved, but just not "atomically" with txn's changes: that would be what they want, presumably (or they wouldn't code funky_save that way). We aren't doing damage by supporting nesting. @silvolu Do the other mappings support nesting? |
Sorry, something went wrong.
|
I'm not saying the functionality is damaging, I'm saying the maintenance burden on us is not worth it. |
Sorry, something went wrong.
|
Hmm, the maintenance / explainability of the consistent / nested one seems easier to me than maintaining / explaining the "Highlander" case. |
Sorry, something went wrong.
|
I suppose you're right. I'm probably just being paranoid. Let's hope it doesn't bite us. |
Sorry, something went wrong.
|
LGTM |
Sorry, something went wrong.
…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://togithub.com/googleapis/synthtool/commit/bb171351c3946d3c3c32e60f5f18cee8c464ec51 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:f62c53736eccb0c4934a3ea9316e0d57696bb49c1a7c86c726e9bb8a2f87dadf
Source-Link: https://togithub.com/googleapis/synthtool/commit/352b9d4c068ce7c05908172af128b294073bf53c Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:3e3800bb100af5d7f9e810d48212b37812c1856d20ffeafb99ebe66461b61fc7
…pprove] (#518) Source-Link: https://togithub.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 <partheniou@google.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
Source-Link: googleapis/synthtool@1b71c10 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:00c9d764fd1cd56265f12a5ef4b99a0c9e87cf261018099141e2ca5158890416 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
* updated CHANGELOG.md [ci skip] * updated setup.py Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
…ination (#518) * chore: Update gapic-generator-python to v1.18.4 PiperOrigin-RevId: 657207628 Source-Link: googleapis/googleapis@33fe71e Source-Link: googleapis/googleapis-gen@e02739d Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTAyNzM5ZDEyMmVkMTViZDVlZjU3NzFjNTdmMTJhODNkNDdhMWRkYSJ9 * 🦉 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>
Fixes #518 We'll need to identify the longer term fix here, but this will unblock current CI failures
Fixes #518 Unpin pytest-asyncio version. Adjust the event_loop fixture to make it compatible with pytest-asyncio>=0.17 Use the @pytest_asyncio.fixture decorator for apropriately.
* updated CHANGELOG.md [ci skip] * updated setup.cfg [ci skip] * updated setup.py Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
🤖 I have created a release \*beep\* \*boop\* --- ## [2.9.0](https://www.github.com/googleapis/python-pubsub/compare/v2.8.0...v2.9.0) (2021-11-10) ### Features * add context manager support in client ([#516](https://www.github.com/googleapis/python-pubsub/issues/516)) ([51eae67](https://www.github.com/googleapis/python-pubsub/commit/51eae67c47e2ce7d2f7620209e98df4a129801b5)) * add support for Python 3.10 ([#518](https://www.github.com/googleapis/python-pubsub/issues/518)) ([bb25d75](https://www.github.com/googleapis/python-pubsub/commit/bb25d755d70ba19e69d8a281be65f13eb994967d)) ### Bug Fixes * add 'dict' annotation type to 'request' ([b72522a](https://www.github.com/googleapis/python-pubsub/commit/b72522a4617c4b2773fb6a5a631038791aa08300)) * **deps:** drop packaging dependency ([290b9c5](https://www.github.com/googleapis/python-pubsub/commit/290b9c5615eaa03674b773a27b756483abd76195)) * **deps:** require google-api-core >= 1.28.0 ([290b9c5](https://www.github.com/googleapis/python-pubsub/commit/290b9c5615eaa03674b773a27b756483abd76195)) * improper types in pagers generation ([2ad639d](https://www.github.com/googleapis/python-pubsub/commit/2ad639d6370c7a085498595d7bd0d7eaadfff3c1)) ### Documentation * add type annotations to codebase ([#509](https://www.github.com/googleapis/python-pubsub/issues/509)) ([093cabf](https://www.github.com/googleapis/python-pubsub/commit/093cabff9f0464b1dfaa8f373b6fffbc439518de)) * list oneofs in docstring ([290b9c5](https://www.github.com/googleapis/python-pubsub/commit/290b9c5615eaa03674b773a27b756483abd76195)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
| Back | FazBrowse Home | New Git URL |
Prep. for #514.