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 — AsyncIO Integration [Part 1] by lidizheng · Pull Request #26 · googleapis/python-api-core

This repository was archived by the owner on Feb 23, 2026. It is now read-only.

Conversation

@lidizheng

@lidizheng lidizheng commented Apr 23, 2020

Copy link
Copy Markdown
Contributor

Since the PR in microgenerator is pretty stable, the existing set of AsyncIO features should be sufficient to support generated code. I plan to split the AsyncIO integration into 3 parts (please let me know if anything I can do to help review): utility modules, LRO related modules, grpc helpers modules.

This PR contains following changes:

  • Nox configuration
  • AsyncIO retry module
  • AsyncIO config parsing module
  • Exception parsing patch
  • Corresponding unit tests

Related #23

Sorry, something went wrong.

Uh oh!

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

All reactions
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Apr 23, 2020
@lidizheng
lidizheng force-pushed the aio-part-1 branch 2 times, most recently from 997a7b5 to 0f9b66f Compare April 23, 2020 21:39
@lidizheng
lidizheng marked this pull request as ready for review April 23, 2020 22:42
@lidizheng

lidizheng commented Apr 23, 2020

Copy link
Copy Markdown
Contributor Author

@busunkim96 PTAL.

All reactions

Sorry, something went wrong.

Uh oh!

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

@lidizheng
lidizheng force-pushed the aio-part-1 branch from bba853d to eaf7aea Compare April 24, 2020 17:22
busunkim96
busunkim96 approved these changes Apr 28, 2020
View reviewed changes

@busunkim96 busunkim96 left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. At some point the docs will need to be updated to include the new classes (https://github.com/googleapis/python-api-core/tree/master/docs). Does it make more sense to do that now or to wait for other parts to be added?

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread tests/asyncio/test_retry_async.py Outdated
@@ -0,0 +1,397 @@
# Copyright 2017 Google LLC

@busunkim96 busunkim96 Apr 28, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Copyright 2017 Google LLC
# Copyright 2020 Google LLC

Sorry, something went wrong.

Uh oh!

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

lidizheng reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread tests/asyncio/gapic/test_config_async.py Resolved

Uh oh!

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

@lidizheng

lidizheng commented Apr 28, 2020

Copy link
Copy Markdown
Contributor Author

@busunkim96 I will add doc in a separate PR. It might be better to update the doc for all new classes once.

All reactions

Sorry, something went wrong.

Uh oh!

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

@lidizheng
lidizheng force-pushed the aio-part-1 branch 2 times, most recently from 4589485 to 97fa36c Compare April 28, 2020 18:39
@lidizheng

lidizheng commented Apr 28, 2020

Copy link
Copy Markdown
Contributor Author

@busunkim96 PTAL at the doc gen code.

After checking the doc generation code, I found you are using Sphinx so it actually is easy to add docs alone the code. So, I will try to add docs templates with code in following PRs.

All reactions

Sorry, something went wrong.

Uh oh!

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

@busunkim96
busunkim96 requested a review from software-dov April 28, 2020 19:29
software-dov
software-dov reviewed Apr 28, 2020
View reviewed changes

@software-dov software-dov left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests look great, just had some nits to pick.

Sorry, something went wrong.

Uh oh!

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

lidizheng reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread google/api_core/gapic_v1/__init__.py Resolved

Uh oh!

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

Comment thread google/api_core/retry_async.py Resolved

Uh oh!

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

Comment thread google/api_core/retry_async.py Resolved

Uh oh!

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

Comment thread google/api_core/retry_async.py Resolved

Uh oh!

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

Comment thread google/api_core/retry_async.py
Args:
target(Callable): The function to call and retry. This must be a
nullary function - apply arguments with `functools.partial`.
predicate (Callable[Exception]): A callable used to determine if an

@software-dov software-dov Apr 28, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a name other than 'predicate' would be more helpful. I like the lisp convention of naming predicates with a -p tail; maybe is_retryable_p

Sorry, something went wrong.

Uh oh!

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

All reactions

@lidizheng lidizheng Apr 28, 2020

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function signature is mimicking the sync version, so we have consistent naming between two versions. I can change if you feel strongly.

Sorry, something went wrong.

Uh oh!

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

All reactions

@software-dov software-dov May 1, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not too strongly, especially if we're trying to preserve a convention.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread google/api_core/retry_async.py Resolved

Uh oh!

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

Comment thread google/api_core/retry_async.py Resolved

Uh oh!

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

Comment thread google/api_core/retry_async.py Outdated
Returns:
AsyncRetry: A new retry instance with the given deadline.
"""
return AsyncRetry(

@software-dov software-dov Apr 28, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worthwhile to add a replace method to AsyncRetry that takes optional parameters corresponding to the constructor params and returns a new AsyncRetry with the passed in overrides applied.

Sorry, something went wrong.

Uh oh!

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

All reactions

@lidizheng lidizheng Apr 28, 2020

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the original designer of this class try to use the builder pattern. Naming each one with_* makes the application code more meaningful semantically. WDYT?

Sorry, something went wrong.

Uh oh!

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

All reactions

@software-dov software-dov May 1, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine preserving the interfaces, but it seems like a lot of boilerplate for a common, straightforward desire: given an object, return a copy with specific fields updated. I think having a replace method that gets called by the with_deadline and with_predicate methods is still a net win.

Sorry, something went wrong.

Uh oh!

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

All reactions

@lidizheng lidizheng May 4, 2020

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to use a common _replace method. Thanks for the suggestion.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread noxfile.py Resolved

Uh oh!

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

Comment thread tests/asyncio/gapic/test_config_async.py
Comment on lines +67 to +73
assert retry._initial == 1.0
assert retry._multiplier == 2.5
assert retry._maximum == 120.0
assert retry._deadline == 600.0
assert timeout._initial == 120.0
assert timeout._multiplier == 1.0
assert timeout._maximum == 120.0

@software-dov software-dov Apr 28, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not define an __eq__ method to handle all this boilerplate? The retry error predicate would still need to be tested by hand, but it would clean this bit up.

Sorry, something went wrong.

Uh oh!

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

All reactions

@lidizheng lidizheng May 4, 2020

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain more about this comment? Do you mean an __eq__ method to compare a retry/timeout object and parsed JSON object?

Sorry, something went wrong.

Uh oh!

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

All reactions
@lidizheng
lidizheng force-pushed the aio-part-1 branch from 97fa36c to c0aa09b Compare April 28, 2020 23:03
lidizheng
lidizheng commented Apr 28, 2020
View reviewed changes

@lidizheng lidizheng left a comment

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@software-dov Thanks for the detailed review. I definitely learned today. PTALA.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread google/api_core/gapic_v1/__init__.py Resolved

Uh oh!

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

Comment thread google/api_core/retry_async.py
Args:
target(Callable): The function to call and retry. This must be a
nullary function - apply arguments with `functools.partial`.
predicate (Callable[Exception]): A callable used to determine if an

@lidizheng lidizheng Apr 28, 2020

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function signature is mimicking the sync version, so we have consistent naming between two versions. I can change if you feel strongly.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread google/api_core/retry_async.py Resolved

Uh oh!

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

Comment thread google/api_core/retry_async.py Resolved

Uh oh!

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

Comment thread google/api_core/retry_async.py Resolved

Uh oh!

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

Comment thread google/api_core/retry_async.py Resolved

Uh oh!

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

Comment thread google/api_core/retry_async.py Resolved

Uh oh!

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

Comment thread google/api_core/retry_async.py Outdated
Returns:
AsyncRetry: A new retry instance with the given deadline.
"""
return AsyncRetry(

@lidizheng lidizheng Apr 28, 2020

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the original designer of this class try to use the builder pattern. Naming each one with_* makes the application code more meaningful semantically. WDYT?

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread google/api_core/retry_async.py Resolved

Uh oh!

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

Comment thread noxfile.py Resolved

Uh oh!

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

@lidizheng

lidizheng commented Apr 29, 2020

Copy link
Copy Markdown
Contributor Author

BTW, I don't have the permission to merge PRs (and I don't have the full context of the release process). So, if there is any blocker, please let me know, no rush.

All reactions

Sorry, something went wrong.

Uh oh!

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

@lidizheng
lidizheng force-pushed the aio-part-1 branch from c0aa09b to a647aba Compare April 30, 2020 18:15
@busunkim96

busunkim96 commented May 1, 2020

Copy link
Copy Markdown
Contributor

@lidizheng There's nothing blocking the release since the changes are additive. Let's release this next week.

Thanks for all your work on this and @software-dov thank you for the thorough review. 😁

lidizheng reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

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

software-dov
software-dov approved these changes May 1, 2020
View reviewed changes

@software-dov software-dov left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. One minor issue, no need to repost if you don't think it's worth the hassle.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread google/api_core/retry_async.py Outdated
Returns:
AsyncRetry: A new retry instance with the given deadline.
"""
return AsyncRetry(

@software-dov software-dov May 1, 2020

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine preserving the interfaces, but it seems like a lot of boilerplate for a common, straightforward desire: given an object, return a copy with specific fields updated. I think having a replace method that gets called by the with_deadline and with_predicate methods is still a net win.

Sorry, something went wrong.

Uh oh!

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

All reactions
@lidizheng
feat: First batch of AIO integration
d2e6ec6
This change includes:
* Nox configuration support for AsynciO unit tests
    * No pre release gRPC Python required
* AsyncIO retry module
* AsyncIO config parsing module
* Exception parsing patch
* Corresponding unit test cases
@lidizheng
lidizheng force-pushed the aio-part-1 branch from a647aba to d2e6ec6 Compare May 4, 2020 17:57
This was referenced May 18, 2020
feat: AsyncIO Integration [Part 2] #28
Merged
feat: AsyncIO Integration [Part 3] #29
Merged
@busunkim96
busunkim96 merged commit a82f289 into googleapis:master May 27, 2020
gcf-merge-on-green Bot pushed a commit that referenced this pull request Jun 2, 2020
@lidizheng
feat: AsyncIO Integration [Part 2] (#28)
dd9b2f3
Children PR of #26.

This PR includes AsyncIO version of:
* Polling future
* Page iterator

The AsyncIO version of polling future still uses the same mechanism as the sync version. The AsyncIO polling future tries to update its own state whenever the application want to access information or perform actions.

For page iterator, it has similar interface design as sync version. But instead of fulfilling normal generator protocol, it is based on the async generator.

Related #23
gcf-merge-on-green Bot pushed a commit that referenced this pull request Jun 4, 2020
@release-please
chore: release 1.18.0 (#33)
33ab7fa
🤖 I have created a release \*beep\* \*boop\* 
---
## [1.18.0](https://www.github.com/googleapis/python-api-core/compare/v1.17.0...v1.18.0) (2020-06-04)


### Features

* [CBT-6 helper] Exposing Retry._deadline as a property ([#20](https://www.github.com/googleapis/python-api-core/issues/20)) ([7be1e59](https://www.github.com/googleapis/python-api-core/commit/7be1e59e9d75c112f346d2b76dce3dd60e3584a1))
* add client_encryped_cert_source to ClientOptions ([#31](https://www.github.com/googleapis/python-api-core/issues/31)) ([e4eaec0](https://www.github.com/googleapis/python-api-core/commit/e4eaec0ff255114138d3715280f86d34d861a6fa))
* AsyncIO Integration [Part 2] ([#28](https://www.github.com/googleapis/python-api-core/issues/28)) ([dd9b2f3](https://www.github.com/googleapis/python-api-core/commit/dd9b2f38a70e85952cc05552ec8070cdf29ddbb4)), closes [#23](https://www.github.com/googleapis/python-api-core/issues/23)
* First batch of AIO integration ([#26](https://www.github.com/googleapis/python-api-core/issues/26)) ([a82f289](https://www.github.com/googleapis/python-api-core/commit/a82f2892b8f219b82e120e6ed9f4070869c28be7))
* third batch of AsyncIO integration ([#29](https://www.github.com/googleapis/python-api-core/issues/29)) ([7d8d580](https://www.github.com/googleapis/python-api-core/commit/7d8d58075a92e93662747d36a2d55b5e9f0943e1))
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please).
@busunkim96 busunkim96 mentioned this pull request Jun 17, 2020
WIP: AsyncIO integration #22
Closed
4 tasks
This was referenced May 30, 2025
chore(main): release 2.0.0 #822
Closed
chore(main): release 2.0.0 #823
Closed
parthea pushed a commit to googleapis/google-cloud-python that referenced this pull request Nov 24, 2025
@lidizheng
feat: AsyncIO Integration [Part 2] (#28)
deaf18b
Children PR of googleapis/python-api-core#26.

This PR includes AsyncIO version of:
* Polling future
* Page iterator

The AsyncIO version of polling future still uses the same mechanism as the sync version. The AsyncIO polling future tries to update its own state whenever the application want to access information or perform actions.

For page iterator, it has similar interface design as sync version. But instead of fulfilling normal generator protocol, it is based on the async generator.

Related #23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

2 more reviewers
@software-dov software-dov software-dov approved these changes
@busunkim96 busunkim96 busunkim96 approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

No one assigned

Labels

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

@lidizheng @busunkim96 @software-dov @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.