GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Using futures in batched requests by dhermes · Pull Request #812 · googleapis/google-cloud-python

Conversation

@dhermes

@dhermes dhermes commented Apr 9, 2015

Copy link
Copy Markdown
Contributor

Has #810 as diffbase.

@tseaver Note this does not support the Iterator subclasses, but I have tested with a fair amount of other requests.

It does enable GET requests, but does so in a somewhat incomplete way.

The main issues are

  1. In Iterator.get_next_page_response
self.next_page_token = response.get('nextPageToken')

fails when response is a _Future
2. In _BucketIterator.get_items_from_response

for item in response.get('items', []):

fails when response is a _Future

The first is easy to deal with (e.g. hasattr(response, 'get')) but the second is not as easy because we need to start an and iterator before knowing what will end up in the response.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@dhermes dhermes added the api: storage Issues related to the Cloud Storage API. label Apr 9, 2015
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Apr 9, 2015
@coveralls

coveralls commented Apr 9, 2015

Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling b50d446 on dhermes:add-future-type into * on GoogleCloudPlatform:master*.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes dhermes mentioned this pull request Apr 9, 2015
Preparing to use futures in storage. #810
Merged
@dhermes
dhermes force-pushed the add-future-type branch from b50d446 to c024bf1 Compare April 9, 2015 18:30
@coveralls

coveralls commented Apr 9, 2015

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling 527cfd1 on dhermes:add-future-type into f08e71b on GoogleCloudPlatform:master.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes
dhermes force-pushed the add-future-type branch from 527cfd1 to f2a9c7d Compare April 11, 2015 00:48
@coveralls

coveralls commented Apr 11, 2015

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling f2a9c7d on dhermes:add-future-type into 028a15d on GoogleCloudPlatform:master.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Apr 11, 2015

Copy link
Copy Markdown
Contributor Author

@tseaver As with #810 I have replaced the original contents from this and placed them in https://github.com/dhermes/gcloud-python/tree/add-future-type-OLD

I was still not able to avoid having each of _helpers and batch reach into each other. From batch:

    def set_future_value(self, value):
        ...
        if self.owner is not None:
            self.owner._properties = value

and from _helpers

    def _set_properties(self, value):
        ...
        if hasattr(value, 'owner'):
            value.owner = self
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes
dhermes force-pushed the add-future-type branch from f2a9c7d to ce9e260 Compare April 12, 2015 19:45
@coveralls

coveralls commented Apr 12, 2015

Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling ce9e260 on dhermes:add-future-type into * on GoogleCloudPlatform:master*.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

dhermes
dhermes reviewed Apr 12, 2015
View reviewed changes
Comment thread gcloud/storage/_helpers.py Outdated

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Apr 19, 2015

Copy link
Copy Markdown
Contributor Author

@tseaver Bump

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes
dhermes force-pushed the add-future-type branch from ce9e260 to b1e4f7d Compare April 21, 2015 05:11
@coveralls

coveralls commented Apr 21, 2015

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling b1e4f7d on dhermes:add-future-type into 286207b on GoogleCloudPlatform:master.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coveralls

coveralls commented Apr 21, 2015

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling f48620f on dhermes:add-future-type into 286207b on GoogleCloudPlatform:master.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Apr 21, 2015

Copy link
Copy Markdown
Contributor Author

@tseaver PTAL. I added two new commits to move towards what we discussed earlier. I'll likely finalize the 4 commits into 1 or 2 once we've finished review, but wanted to keep the "history" of ideas around.

Note that still "unsupported" are:

  • _BucketIterator
  • _BlobIterator
  • (Blob|Bucket).exists() (FYI these should be consolidated into _PropertyMixin someday when STORAGE: Does a connection need to be bound to anything other than a Batch or Iterator? #728 is done)
  • Anything in ACL, which we still need to discuss (tried to in Storage "Interface Driven Design" Document #761)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver

tseaver commented Apr 21, 2015

Copy link
Copy Markdown
Contributor

Ugh, sorry -- those comments are on the individual commits.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

dhermes
dhermes reviewed Apr 22, 2015
View reviewed changes
Comment thread gcloud/connection.py Outdated

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coveralls

coveralls commented Apr 23, 2015

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling 4a97272 on dhermes:add-future-type into 286207b on GoogleCloudPlatform:master.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver

tseaver commented Apr 27, 2015

Copy link
Copy Markdown
Contributor

LGTM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Apr 27, 2015

Copy link
Copy Markdown
Contributor Author

@tseaver We still have some pending discussion points.

Things to resolve:

  • Never addressed issue of broken / different behavior of
    (Blob|Bucket).exists().
  • Use of the dummy argument
  • Should we to support or disable paging in a batch? I am leaning towards disabling, but currently we have no way to send the storage.<NOUN>.list requests without using the paging utils.
  • We currently have "inconsistent" support for GET requests. How to move forward?

Also, are you OK with me squashing into fewer ad-hoc commits here or should I submit a new PR?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver

tseaver commented Apr 30, 2015

Copy link
Copy Markdown
Contributor

Never addressed issue of broken / different behavior of (Blob|Bucket).exists().

  • Use of the dummy argument

The superclass defines the contract for overridable methods: it must use the same argument names as the ones in the subclasses. This would be another case for an exception to the line-markers (assuming we don't want to disable the check altogether, which is reasonable in my mind for arguments, as opposed to locals defined in the suite).

  • Should we to support or disable paging in a batch? I am leaning towards disabling, but currently we have no way to send the storage..list requests without using the paging utils.

I remain pretty unconvinced of the utility of any GET methods in a batch, so I'm fine with disabling the "collection GET" (or crippling them) inside a batch.

We currently have "inconsistent" support for GET requests. How to move forward?

I'm not sure we have a good story at all for how applications would use GET requests inside a batch.

Also, are you OK with me squashing into fewer ad-hoc commits here or should I submit a new PR?

I'm not fussy about the number of commits in a PR: I certainly wouldn't submit a new one just to clean up history. If squashing them makes you feel better about mergeing, I'm OK with it (but it does mean an indefinitely long delay for the merge, given the current Travis delays).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes
dhermes force-pushed the add-future-type branch from 4a97272 to 301c945 Compare May 4, 2015 18:33
@coveralls

coveralls commented May 4, 2015

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling 301c945 on dhermes:add-future-type into 8b5c5b9 on GoogleCloudPlatform:master.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

dhermes added 6 commits May 4, 2015 14:28
@dhermes
Adding _FutureDict type for storage batches.
2e73689
@dhermes
Using futures in batched requests.
7821e1c
Also removing limitation on GETs in batch requests.
@dhermes
Chaning JSONConnection methods to accept a target object.
c261d0a
This is to allow storage.Batch.finish() to update properties on
objects from requests.
@dhermes
Sending along callers of JSONConnection.api_request as _target_object.
eb8c984
@dhermes
Addressing content-type and renaming Batch._futures.
d89f684
NOTE: This commit made for review but will be folded into
      originals before merged.
@dhermes
Dropping dummy argument for target_object.
4564992
Had to trade-off here and use `# pylint: disable=unused-argument`.
@dhermes
dhermes force-pushed the add-future-type branch from 301c945 to 4564992 Compare May 4, 2015 21:30
@coveralls

coveralls commented May 5, 2015

Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling 4564992 on dhermes:add-future-type into * on GoogleCloudPlatform:master*.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

dhermes added a commit that referenced this pull request May 5, 2015
@dhermes
Merge pull request #812 from dhermes/add-future-type
73a341c
Using futures in batched requests
@dhermes
dhermes merged commit 73a341c into googleapis:master May 5, 2015
@dhermes

dhermes commented May 5, 2015

Copy link
Copy Markdown
Contributor Author

@tseaver I just merged, we can continue the discussion when dealing with crippling the iterators.

You never mentioned if the behavior of Blob.exists() (and Bucket.exists()) was concerning.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes
dhermes deleted the add-future-type branch May 5, 2015 17:56
@tseaver

tseaver commented May 5, 2015

Copy link
Copy Markdown
Contributor

Hmm, why doesn't the comment in Bucket.exists apply to Blob.exists, too? Surely we don't want to wipe out blob metadata due to an existence check?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented May 5, 2015

Copy link
Copy Markdown
Contributor Author

Oversight. My bad.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented May 5, 2015

Copy link
Copy Markdown
Contributor Author

Gonna wrap it into the PR for turning off batching for iterators.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced May 6, 2015
Making Blob.exists() work as Bucket.exists(). #862
Merged
_PropertyMixin.patch() does not work as expected in a batch #736
Closed
@dhermes dhermes mentioned this pull request Jun 4, 2015
Upgrading version to 0.6.0. #907
Merged
parthea pushed a commit that referenced this pull request Aug 21, 2025
@gcf-owl-bot @Linchin
chore: removes docs-presubmit.cfg template (#812)
168ff06
Source-Link: googleapis/synthtool@373d00f
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:2dc6f67639bee669c33c6277a624ab9857d363e2fd33ac5b02d417b7d25f1ffc

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Lingqing Gan <[email protected]>
parthea pushed a commit that referenced this pull request Sep 16, 2025
@gcf-owl-bot @Linchin @parthea
chore: removes docs-presubmit.cfg template (#812)
eb03dbd
Source-Link: googleapis/synthtool@373d00f
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:2dc6f67639bee669c33c6277a624ab9857d363e2fd33ac5b02d417b7d25f1ffc

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Lingqing Gan <[email protected]>
parthea pushed a commit that referenced this pull request Nov 24, 2025
@renovate-bot
chore(deps): update dependency protobuf to v3.15.6 (#812)
a249600
parthea added a commit that referenced this pull request Nov 24, 2025
@parthea
feat: Add protobuf runtime version to x-goog-api-client header (#812)
e8a65cb
* for testing purposes

* lint
parthea added a commit that referenced this pull request Nov 24, 2025
@gkevinzheng @gcf-owl-bot @parthea
feat: use native namespaces instead of pkg_resources (#812)
9c6040a
* feat: use native namespaces instead of pkg_resources

* linting

* Added packaging test for native namespace support.

* 🦉 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>
Co-authored-by: Anthonios Partheniou <[email protected]>
parthea pushed a commit that referenced this pull request Nov 24, 2025
@bw-yuhogg
chore: Remove andrewsg from CODEOWNERS (#812)
a3a9e02
parthea added a commit that referenced this pull request Nov 25, 2025
@gkevinzheng @gcf-owl-bot @parthea
feat: use native namespaces instead of pkg_resources (#812)
8918c60
* feat: use native namespaces instead of pkg_resources

* linting

* Added packaging test for native namespace support.

* 🦉 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>
Co-authored-by: Anthonios Partheniou <[email protected]>
parthea pushed a commit that referenced this pull request Nov 26, 2025
@bojeil-google
feat: support refresh callable on google.oauth2.credentials.Credentia…
0c048b4
…ls (#812)

This is an optional parameter that can be set via the constructor.
It is used to provide the credentials with new tokens and their
expiration time on `refresh()` call.

```
def refresh_handler(request, scopes):
    # Generate a new token for the requested scopes by calling
    # an external process.
    return (
        "ACCESS_TOKEN",
        _helpers.utcnow() + datetime.timedelta(seconds=3600))

creds = google.oauth2.credentials.Credentials(
    scopes=scopes,
    refresh_handler=refresh_handler)
creds.refresh(request)
```

It is useful in the following cases:
- Useful in general when tokens are obtained by calling some
  external process on demand.
- Useful in particular for retrieving downscoped tokens from a
  token broker.

This should have no impact on existing behavior. Refresh tokens
will still have higher priority over refresh handlers.

A getter and setter is exposed to make it easy to set the callable
on unpickled credentials as the callable may not be easily serialized.

```
unpickled = pickle.loads(pickle.dumps(oauth_creds))
unpickled.refresh_handler = refresh_handler
```
parthea pushed a commit that referenced this pull request Mar 9, 2026
@release-please
chore(main): release 3.21.0 (#812)
dc5ea80
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

api: storage Issues related to the Cloud Storage API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@dhermes @coveralls @tseaver @googlebot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.