Skip to content
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

feat: merge main branch into v1 #473

Closed
wants to merge 127 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
ff6ef1b
fix: strip trailing _ from field mask paths (#228)
busunkim96 Aug 3, 2021
a30f004
fix!: drop support for Python 2.7 / 3.5 (#212)
tseaver Aug 3, 2021
d566f28
chore: release 2.0.0b1 (#243)
release-please[bot] Aug 3, 2021
6789e67
chore: remove non-custom rules from sync-repo-settings (#241)
busunkim96 Aug 6, 2021
258ba4a
chore(python): avoid `.nox` directories when building docs (#249)
gcf-owl-bot[bot] Aug 12, 2021
ffa528e
chore: avoid duplicating pins of grpcio in noxfile (#246)
tseaver Aug 12, 2021
a54cc10
chore: drop mention of Python 2.7 from templates (#252)
gcf-owl-bot[bot] Aug 13, 2021
362ca6c
chore: update if_transient_error docs to match behaviour (#253)
parthea Aug 13, 2021
bdbf889
fix: bump grpcio version to use stable aio API (#234)
lidizheng Aug 13, 2021
bb3b26d
tests: silence a warning from 'charset_normalizer' (#247)
tseaver Aug 18, 2021
40f52bf
chore: release 2.0.0 (#254)
release-please[bot] Aug 18, 2021
e3d34d4
chore(python): disable dependency dashboard (#266)
gcf-owl-bot[bot] Aug 30, 2021
1db493c
chore: migrate default branch to main (#264)
tseaver Aug 30, 2021
82ca2fd
tests: close coverage gap for race condition (#261)
tseaver Aug 31, 2021
618f192
fix: do not error on LROs with no response or error (#258)
busunkim96 Aug 31, 2021
dcb6ebd
chore: release 2.0.1 (#267)
release-please[bot] Aug 31, 2021
01e31ca
chore(python): group renovate prs (#270)
gcf-owl-bot[bot] Sep 1, 2021
4679219
chore: remove obsolete dependency in setup.py (#269)
parthea Sep 1, 2021
8b65c93
chore: removing owlbot directives for conversion to main (#272)
nicain Sep 3, 2021
afe0fa1
feat: add grpc transcoding + tests (#259)
yihjenku Sep 15, 2021
1c5eb4d
feat: Add helper function to format query_params for rest transport. …
kbandes Sep 20, 2021
083e6e9
chore: relocate owl bot post processor (#280)
SurferJeffAtGoogle Sep 21, 2021
3b0912a
tests: add explicit unit tests for '_StreamedResponseIterator' class …
tseaver Sep 27, 2021
f3fd059
chore: add default_version and codeowner_team to .repo-metadata.json …
parthea Oct 4, 2021
577da9d
build: use trampoline_v2 for python samples and allow custom dockerfi…
gcf-owl-bot[bot] Oct 5, 2021
a422a5d
feat: add support for Python 3.10 (#284)
tseaver Oct 5, 2021
121debd
chore: release 2.1.0 (#274)
release-please[bot] Oct 5, 2021
e6a3489
chore(python): Add kokoro configs for python 3.10 samples testing (#285)
gcf-owl-bot[bot] Oct 8, 2021
0023ee1
fix: add mypy checking + 'py.typed' file (#290)
tseaver Oct 13, 2021
f4e776e
chore: release 2.1.1 (#291)
release-please[bot] Oct 13, 2021
09cf285
tests: add testing w/o 'grpc' installed (#289)
tseaver Oct 19, 2021
ef6f0fc
feat: add 'GoogleAPICallError.error_details' property (#286)
atulep Oct 19, 2021
5f4fb50
chore(python): push cloud library docs to staging bucket for Cloud RA…
gcf-owl-bot[bot] Oct 25, 2021
240edb6
chore: release 2.2.0 (#293)
release-please[bot] Oct 26, 2021
9e6091e
fix: revert "fix: do not error on LROs with no response or error" (#294)
busunkim96 Oct 26, 2021
d2a729e
chore: release 2.2.1 (#296)
release-please[bot] Oct 28, 2021
ffc51f0
fix: make 'gapic_v1.method.DEFAULT' a typed object (#292)
tseaver Nov 2, 2021
214d88b
chore: release 2.2.2 (#302)
release-please[bot] Nov 2, 2021
060b339
fix: handle bare 'grpc.Call' in 'from_grpc_error' (#298)
tseaver Nov 3, 2021
4b40789
chore(python): add .github/CODEOWNERS as a templated file (#308)
gcf-owl-bot[bot] Nov 11, 2021
bc0abe4
ci: tweak mypy to check 'google.protobuf' (#310)
tseaver Nov 18, 2021
ce1adf3
feat: add operations rest client to support long-running operations. …
kbandes Nov 25, 2021
cb091f8
chore: release 2.3.0 (#314)
release-please[bot] Dec 7, 2021
479d6a7
ci: run lint / mypy / unit tests / coverage as GH actions (#287)
tseaver Dec 8, 2021
cc46aa6
feat: add support for 'error_info' (#315)
atulep Dec 9, 2021
34ebdcc
fix: exclude function target from retry deadline exceeded exception m…
sushicw Dec 15, 2021
6538e03
chore: use python-samples-reviewers (#328)
gcf-owl-bot[bot] Jan 6, 2022
69a99d8
chore: update release_level in repo-metadata.json (#326)
parthea Jan 7, 2022
f9f2696
feat: iterator for processing JSON responses in REST streaming. (#317)
atulep Jan 10, 2022
beb3e63
chore: release 2.4.0 (#316)
release-please[bot] Jan 11, 2022
adbe638
build: switch to release-please for tagging (#331)
gcf-owl-bot[bot] Jan 13, 2022
f267111
docs: fix typo in library name (#332)
anguillanneuf Jan 14, 2022
8169f2b
chore(python): update release.sh to use keystore (#333)
gcf-owl-bot[bot] Jan 14, 2022
74d5ce8
chore: move docs check from kokoro to GH actions (#334)
parthea Jan 17, 2022
5e5ad37
feat: add api_key to client options (#248)
arithmetic1728 Jan 19, 2022
95e41ff
ci(python): run lint / unit tests / docs as GH actions (#336)
gcf-owl-bot[bot] Jan 22, 2022
c782f29
fix(deps): remove setuptools from dependencies (#339)
busunkim96 Feb 2, 2022
4422cce
chore(main): release 2.5.0 (#335)
release-please[bot] Feb 2, 2022
b558e3d
chore(deps): update actions/setup-python action to v3 (#346)
gcf-owl-bot[bot] Mar 1, 2022
6f61491
chore(deps): update all dependencies to v3 (#347)
renovate-bot Mar 2, 2022
021bb7d
feat: initial support for Extended Operations (#344)
software-dov Mar 2, 2022
a226a7c
chore(deps): update actions/checkout action to v3 (#349)
gcf-owl-bot[bot] Mar 3, 2022
04a8b8b
chore(main): release 2.6.0 (#350)
release-please[bot] Mar 3, 2022
7e21e9e
fix: Remove py2 tag from wheel (#343)
hugovk Mar 5, 2022
07747ca
chore(main): release 2.6.1 (#352)
release-please[bot] Mar 7, 2022
9abc6f4
feat: expose extra fields in ExtendedOperation (#351)
software-dov Mar 8, 2022
ea41551
chore(main): release 2.7.0 (#353)
release-please[bot] Mar 8, 2022
0680fb4
fix: add more context to error message. (#340)
atulep Mar 9, 2022
c89f55d
chore(main): release 2.7.1 (#354)
release-please[bot] Mar 9, 2022
112049e
fix: allow grpc without grpcio-status (#355)
parthea Mar 15, 2022
778d27d
chore(python): use black==22.3.0 (#362)
gcf-owl-bot[bot] Mar 30, 2022
7186e36
chore(python): update .pre-commit-config.yaml to use black==22.3.0 (#…
gcf-owl-bot[bot] Apr 1, 2022
45b0b52
chore(python): Enable size-label bot (#364)
gcf-owl-bot[bot] Apr 1, 2022
caba5f2
chore(python): add license header to auto-label.yaml (#365)
gcf-owl-bot[bot] Apr 6, 2022
523dbd0
fix: remove dependency on pkg_resources (#361)
parthea Apr 13, 2022
319c026
chore(main): release 2.7.2 (#358)
release-please[bot] Apr 13, 2022
12f7667
chore(deps): update all dependencies (#367)
renovate-bot Apr 21, 2022
4497873
chore(python): use ubuntu 22.04 in docs image (#368)
gcf-owl-bot[bot] Apr 21, 2022
022add1
fix: Avoid AttributeError if grpcio-status is not installed (#370)
ddoskind Apr 26, 2022
64802e1
test: use `not` instead of `is False` in assert (#366)
parthea Apr 26, 2022
1ce2e54
test: fix KeyError in test_rest_streaming.py (#373)
parthea Apr 29, 2022
52366f2
chore(main): release 2.7.3 (#371)
release-please[bot] May 2, 2022
364776c
chore: [autoapprove] update readme_gen.py to include autoescape True …
gcf-owl-bot[bot] May 5, 2022
cddc802
chore(python): auto approve template changes (#376)
gcf-owl-bot[bot] May 5, 2022
c97c498
feat: adds support for audience in client_options (#379)
atulep May 18, 2022
eed844f
chore(main): release 2.8.0 (#381)
release-please[bot] May 18, 2022
d84d66c
fix(deps): require protobuf>= 3.15.0, <4.0.0dev (#385)
parthea May 26, 2022
9be727d
chore(main): release 2.8.1 (#386)
release-please[bot] May 26, 2022
0c4668d
chore: allow releases from older version branches (#388)
parthea May 27, 2022
ac266e9
docs: fix changelog header to consistent size (#394)
dandhlee Jun 2, 2022
0eb727f
docs: Fix typo in the BackgroundConsumer docstring (#395)
Mariatta Jun 2, 2022
e92045b
chore: test minimum dependencies in python 3.7 (#397)
parthea Jun 3, 2022
5da6733
fix: drop support for grpc-gcp (#401)
parthea Jun 13, 2022
8f73d2e
fix(deps): allow protobuf < 5.0.0 (#400)
parthea Jun 13, 2022
5b5e775
chore(main): release 2.8.2 (#396)
release-please[bot] Jun 14, 2022
7ddb8c0
fix: require python 3.7+ (#410)
gcf-owl-bot[bot] Aug 10, 2022
cb0329a
chore(deps): update actions/setup-python action to v4 (#419)
renovate-bot Aug 10, 2022
7472e6d
doc: Update gcloud command for ADC (#406)
sai-sunder-s Aug 10, 2022
0dde0f9
chore: remove 'pip install' statements from python_library templates …
gcf-owl-bot[bot] Aug 24, 2022
d1026e7
chore(python): exclude path in renovate.json [autoapprove] (#425)
gcf-owl-bot[bot] Aug 24, 2022
7371d02
chore(python): update dependency distlib (#429)
gcf-owl-bot[bot] Aug 30, 2022
c3ad8ea
feat: Make grpc transcode logic work in terms of protobuf python obje…
vam-google Aug 30, 2022
29aa9ef
chore: fix path to requirements.txt in release script [autoapprove] (…
gcf-owl-bot[bot] Sep 1, 2022
8c19609
fix: restore support for grpcio-gcp (#418)
parthea Sep 1, 2022
922f468
chore(main): release 2.9.0 (#422)
release-please[bot] Sep 1, 2022
9066ed4
chore(python): update .kokoro/requirements.txt (#431)
gcf-owl-bot[bot] Sep 1, 2022
83678e9
feat: add 'strict' to flatten_query_params to lower-case bools (#433)
vchudnov-g Sep 2, 2022
cea67da
chore(main): release 2.10.0 (#434)
release-please[bot] Sep 2, 2022
fe617c2
chore(python): exclude setup.py in renovate config (#436)
gcf-owl-bot[bot] Sep 2, 2022
538df80
fix: Improve transcoding error message (#442)
vam-google Sep 14, 2022
b1f9957
chore(main): release 2.10.1 (#443)
release-please[bot] Sep 14, 2022
4420055
fix(deps): require protobuf >= 3.20.2 (#455)
gcf-owl-bot[bot] Sep 29, 2022
e949364
fix(deps): allow protobuf 3.19.5 (#459)
parthea Oct 8, 2022
ddcc249
chore(main): release 2.10.2 (#456)
release-please[bot] Oct 8, 2022
434253d
fix: Major refactoring of Polling, Retry and Timeout logic (#462)
vam-google Nov 10, 2022
7cc329f
fix: require google-auth >= 2.14.1 (#463)
aribray Nov 10, 2022
83ce2d7
chore(python): update dependencies in .kokoro/requirements.txt [autoa…
gcf-owl-bot[bot] Nov 10, 2022
ff379e3
feat: add support for Python 3.11 (#466)
ziegenberg Nov 10, 2022
522b98e
feat: Allow representing enums with their unqualified symbolic names …
vchudnov-g Nov 10, 2022
cb5e2f2
chore(main): release 2.11.0 (#468)
release-please[bot] Dec 1, 2022
ce77381
chore(python): update release script dependencies (#472)
gcf-owl-bot[bot] Dec 1, 2022
22eeaa9
Merge remote-tracking branch 'origin/main' into v1
parthea Dec 1, 2022
758a30d
update python version for docs
parthea Dec 1, 2022
8f15fb3
revert testing/constraints-3.8.txt
parthea Dec 1, 2022
aac0a8c
lint
parthea Dec 1, 2022
c289e4d
update python version for lint
parthea Dec 1, 2022
147d097
update python version for lint
parthea Dec 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.9"
- name: Install nox
run: |
python -m pip install --upgrade setuptools pip wheel
Expand All @@ -28,7 +28,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.9"
- name: Install nox
run: |
python -m pip install --upgrade setuptools pip wheel
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.7"
python-version: "3.10"
- name: Install nox
run: |
python -m pip install --upgrade setuptools pip wheel
Expand Down
4 changes: 3 additions & 1 deletion .kokoro/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ typing-extensions
twine
wheel
setuptools
nox
nox
charset-normalizer<3
click<8.1.0
355 changes: 193 additions & 162 deletions .kokoro/requirements.txt

Large diffs are not rendered by default.

28 changes: 19 additions & 9 deletions google/api_core/extended_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ class ExtendedOperation(polling.PollingFuture):
refresh (Callable[[], type(extended_operation)]): A callable that returns
the latest state of the operation.
cancel (Callable[[], None]): A callable that tries to cancel the operation.
retry: Optional(google.api_core.retry.Retry): The retry configuration used
when polling. This can be used to control how often :meth:`done`
is polled. Regardless of the retry's ``deadline``, it will be
overridden by the ``timeout`` argument to :meth:`result`.
polling Optional(google.api_core.retry.Retry): The configuration used
for polling. This can be used to control how often :meth:`done`
is polled. If the ``timeout`` argument to :meth:`result` is
specified it will override the ``polling.timeout`` property.
retry Optional(google.api_core.retry.Retry): DEPRECATED use ``polling``
instead. If specified it will override ``polling`` parameter to
maintain backward compatibility.

Note: Most long-running API methods use google.api_core.operation.Operation
This class is a wrapper for a subset of methods that use alternative
Expand All @@ -68,9 +71,14 @@ class ExtendedOperation(polling.PollingFuture):
"""

def __init__(
self, extended_operation, refresh, cancel, retry=polling.DEFAULT_RETRY
self,
extended_operation,
refresh,
cancel,
polling=polling.DEFAULT_POLLING,
**kwargs,
):
super().__init__(retry=retry)
super().__init__(polling=polling, **kwargs)
self._extended_operation = extended_operation
self._refresh = refresh
self._cancel = cancel
Expand Down Expand Up @@ -114,7 +122,7 @@ def error_message(self):
def __getattr__(self, name):
return getattr(self._extended_operation, name)

def done(self, retry=polling.DEFAULT_RETRY):
def done(self, retry=None):
self._refresh_and_update(retry)
return self._extended_operation.done

Expand All @@ -137,9 +145,11 @@ def cancelled(self):
self._refresh_and_update()
return self._extended_operation.done

def _refresh_and_update(self, retry=polling.DEFAULT_RETRY):
def _refresh_and_update(self, retry=None):
if not self._extended_operation.done:
self._extended_operation = self._refresh(retry=retry)
self._extended_operation = (
self._refresh(retry=retry) if retry else self._refresh()
)
self._handle_refreshed_operation()

def _handle_refreshed_operation(self):
Expand Down
2 changes: 1 addition & 1 deletion google/api_core/future/async_future.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async def _blocking_poll(self, timeout=None):
if self._future.done():
return

retry_ = self._retry.with_deadline(timeout)
retry_ = self._retry.with_timeout(timeout)

try:
await retry_(self._done_or_raise)()
Expand Down
200 changes: 165 additions & 35 deletions google/api_core/future/polling.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import concurrent.futures

from google.api_core import exceptions
from google.api_core import retry
from google.api_core import retry as retries
from google.api_core.future import _helpers
from google.api_core.future import base

Expand All @@ -29,14 +29,37 @@ class _OperationNotComplete(Exception):
pass


RETRY_PREDICATE = retry.if_exception_type(
# DEPRECATED as it conflates RPC retry and polling concepts into one.
# Use POLLING_PREDICATE instead to configure polling.
RETRY_PREDICATE = retries.if_exception_type(
_OperationNotComplete,
exceptions.TooManyRequests,
exceptions.InternalServerError,
exceptions.BadGateway,
exceptions.ServiceUnavailable,
)
DEFAULT_RETRY = retry.Retry(predicate=RETRY_PREDICATE)

# DEPRECATED: use DEFAULT_POLLING to configure LRO polling logic. Construct
# Retry object using its default values as a baseline for any custom retry logic
# (not to be confused with polling logic).
DEFAULT_RETRY = retries.Retry(predicate=RETRY_PREDICATE)

# POLLING_PREDICATE is supposed to poll only on _OperationNotComplete.
# Any RPC-specific errors (like ServiceUnavailable) will be handled
# by retry logic (not to be confused with polling logic) which is triggered for
# every polling RPC independently of polling logic but within its context.
POLLING_PREDICATE = retries.if_exception_type(
_OperationNotComplete,
)

# Default polling configuration
DEFAULT_POLLING = retries.Retry(
predicate=POLLING_PREDICATE,
initial=1.0, # seconds
maximum=20.0, # seconds
multiplier=1.5,
timeout=900, # seconds
)


class PollingFuture(base.Future):
Expand All @@ -45,21 +68,29 @@ class PollingFuture(base.Future):
The :meth:`done` method should be implemented by subclasses. The polling
behavior will repeatedly call ``done`` until it returns True.

The actuall polling logic is encapsulated in :meth:`result` method. See
documentation for that method for details on how polling works.

.. note::

Privacy here is intended to prevent the final class from
overexposing, not to prevent subclasses from accessing methods.

Args:
retry (google.api_core.retry.Retry): The retry configuration used
when polling. This can be used to control how often :meth:`done`
is polled. Regardless of the retry's ``deadline``, it will be
overridden by the ``timeout`` argument to :meth:`result`.
polling (google.api_core.retry.Retry): The configuration used for polling.
This parameter controls how often :meth:`done` is polled. If the
``timeout`` argument is specified in :meth:`result` method it will
override the ``polling.timeout`` property.
retry (google.api_core.retry.Retry): DEPRECATED use ``polling`` instead.
If set, it will override ``polling`` paremeter for backward
compatibility.
"""

def __init__(self, retry=DEFAULT_RETRY):
_DEFAULT_VALUE = object()

def __init__(self, polling=DEFAULT_POLLING, **kwargs):
super(PollingFuture, self).__init__()
self._retry = retry
self._polling = kwargs.get("retry", polling)
self._result = None
self._exception = None
self._result_set = False
Expand All @@ -69,57 +100,150 @@ def __init__(self, retry=DEFAULT_RETRY):
self._done_callbacks = []

@abc.abstractmethod
def done(self, retry=DEFAULT_RETRY):
def done(self, retry=None):
"""Checks to see if the operation is complete.

Args:
retry (google.api_core.retry.Retry): (Optional) How to retry the RPC.
retry (google.api_core.retry.Retry): (Optional) How to retry the
polling RPC (to not be confused with polling configuration. See
the documentation for :meth:`result` for details).

Returns:
bool: True if the operation is complete, False otherwise.
"""
# pylint: disable=redundant-returns-doc, missing-raises-doc
raise NotImplementedError()

def _done_or_raise(self, retry=DEFAULT_RETRY):
def _done_or_raise(self, retry=None):
"""Check if the future is done and raise if it's not."""
kwargs = {} if retry is DEFAULT_RETRY else {"retry": retry}

if not self.done(**kwargs):
if not self.done(retry=retry):
raise _OperationNotComplete()

def running(self):
"""True if the operation is currently running."""
return not self.done()

def _blocking_poll(self, timeout=None, retry=DEFAULT_RETRY):
"""Poll and wait for the Future to be resolved.
def _blocking_poll(self, timeout=_DEFAULT_VALUE, retry=None, polling=None):
"""Poll and wait for the Future to be resolved."""

Args:
timeout (int):
How long (in seconds) to wait for the operation to complete.
If None, wait indefinitely.
"""
if self._result_set:
return

retry_ = self._retry.with_deadline(timeout)
polling = polling or self._polling
if timeout is not PollingFuture._DEFAULT_VALUE:
polling = polling.with_timeout(timeout)

try:
kwargs = {} if retry is DEFAULT_RETRY else {"retry": retry}
retry_(self._done_or_raise)(**kwargs)
polling(self._done_or_raise)(retry=retry)
except exceptions.RetryError:
raise concurrent.futures.TimeoutError(
"Operation did not complete within the designated " "timeout."
f"Operation did not complete within the designated timeout of "
f"{polling.timeout} seconds."
)

def result(self, timeout=None, retry=DEFAULT_RETRY):
"""Get the result of the operation, blocking if necessary.
def result(self, timeout=_DEFAULT_VALUE, retry=None, polling=None):
"""Get the result of the operation.

This method will poll for operation status periodically, blocking if
necessary. If you just want to make sure that this method does not block
for more than X seconds and you do not care about the nitty-gritty of
how this method operates, just call it with ``result(timeout=X)``. The
other parameters are for advanced use only.

Every call to this method is controlled by the following three
parameters, each of which has a specific, distinct role, even though all three
may look very similar: ``timeout``, ``retry`` and ``polling``. In most
cases users do not need to specify any custom values for any of these
parameters and may simply rely on default ones instead.

If you choose to specify custom parameters, please make sure you've
read the documentation below carefully.

First, please check :class:`google.api_core.retry.Retry`
class documentation for the proper definition of timeout and deadline
terms and for the definition the three different types of timeouts.
This class operates in terms of Retry Timeout and Polling Timeout. It
does not let customizing RPC timeout and the user is expected to rely on
default behavior for it.

The roles of each argument of this method are as follows:

``timeout`` (int): (Optional) The Polling Timeout as defined in
:class:`google.api_core.retry.Retry`. If the operation does not complete
within this timeout an exception will be thrown. This parameter affects
neither Retry Timeout nor RPC Timeout.

``retry`` (google.api_core.retry.Retry): (Optional) How to retry the
polling RPC. The ``retry.timeout`` property of this parameter is the
Retry Timeout as defined in :class:`google.api_core.retry.Retry`.
This parameter defines ONLY how the polling RPC call is retried
(i.e. what to do if the RPC we used for polling returned an error). It
does NOT define how the polling is done (i.e. how frequently and for
how long to call the polling RPC); use the ``polling`` parameter for that.
If a polling RPC throws and error and retrying it fails, the whole
future fails with the corresponding exception. If you want to tune which
server response error codes are not fatal for operation polling, use this
parameter to control that (``retry.predicate`` in particular).

``polling`` (google.api_core.retry.Retry): (Optional) How often and
for how long to call the polling RPC periodically (i.e. what to do if
a polling rpc returned successfully but its returned result indicates
that the long running operation is not completed yet, so we need to
check it again at some point in future). This parameter does NOT define
how to retry each individual polling RPC in case of an error; use the
``retry`` parameter for that. The ``polling.timeout`` of this parameter
is Polling Timeout as defined in as defined in
:class:`google.api_core.retry.Retry`.

For each of the arguments, there are also default values in place, which
will be used if a user does not specify their own. The default values
for the three parameters are not to be confused with the default values
for the corresponding arguments in this method (those serve as "not set"
markers for the resolution logic).

If ``timeout`` is provided (i.e.``timeout is not _DEFAULT VALUE``; note
the ``None`` value means "infinite timeout"), it will be used to control
the actual Polling Timeout. Otherwise, the ``polling.timeout`` value
will be used instead (see below for how the ``polling`` config itself
gets resolved). In other words, this parameter effectively overrides
the ``polling.timeout`` value if specified. This is so to preserve
backward compatibility.

If ``retry`` is provided (i.e. ``retry is not None``) it will be used to
control retry behavior for the polling RPC and the ``retry.timeout``
will determine the Retry Timeout. If not provided, the
polling RPC will be called with whichever default retry config was
specified for the polling RPC at the moment of the construction of the
polling RPC's client. For example, if the polling RPC is
``operations_client.get_operation()``, the ``retry`` parameter will be
controlling its retry behavior (not polling behavior) and, if not
specified, that specific method (``operations_client.get_operation()``)
will be retried according to the default retry config provided during
creation of ``operations_client`` client instead. This argument exists
mainly for backward compatibility; users are very unlikely to ever need
to set this parameter explicitly.

If ``polling`` is provided (i.e. ``polling is not None``), it will be used
to controll the overall polling behavior and ``polling.timeout`` will
controll Polling Timeout unless it is overridden by ``timeout`` parameter
as described above. If not provided, the``polling`` parameter specified
during construction of this future (the ``polling`` argument in the
constructor) will be used instead. Note: since the ``timeout`` argument may
override ``polling.timeout`` value, this parameter should be viewed as
coupled with the ``timeout`` parameter as described above.

Args:
timeout (int):
How long (in seconds) to wait for the operation to complete.
If None, wait indefinitely.
timeout (int): (Optional) How long (in seconds) to wait for the
operation to complete. If None, wait indefinitely.
retry (google.api_core.retry.Retry): (Optional) How to retry the
polling RPC. This defines ONLY how the polling RPC call is
retried (i.e. what to do if the RPC we used for polling returned
an error). It does NOT define how the polling is done (i.e. how
frequently and for how long to call the polling RPC).
polling (google.api_core.retry.Retry): (Optional) How often and
for how long to call polling RPC periodically. This parameter
does NOT define how to retry each individual polling RPC call
(use the ``retry`` parameter for that).

Returns:
google.protobuf.Message: The Operation's result.
Expand All @@ -128,8 +252,8 @@ def result(self, timeout=None, retry=DEFAULT_RETRY):
google.api_core.GoogleAPICallError: If the operation errors or if
the timeout is reached before the operation completes.
"""
kwargs = {} if retry is DEFAULT_RETRY else {"retry": retry}
self._blocking_poll(timeout=timeout, **kwargs)

self._blocking_poll(timeout=timeout, retry=retry, polling=polling)

if self._exception is not None:
# pylint: disable=raising-bad-type
Expand All @@ -138,12 +262,18 @@ def result(self, timeout=None, retry=DEFAULT_RETRY):

return self._result

def exception(self, timeout=None):
def exception(self, timeout=_DEFAULT_VALUE):
"""Get the exception from the operation, blocking if necessary.

See the documentation for the :meth:`result` method for details on how
this method operates, as both ``result`` and this method rely on the
exact same polling logic. The only difference is that this method does
not accept ``retry`` and ``polling`` arguments but relies on the default ones
instead.

Args:
timeout (int): How long to wait for the operation to complete.
If None, wait indefinitely.
If None, wait indefinitely.

Returns:
Optional[google.api_core.GoogleAPICallError]: The operation's
Expand Down
Loading