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 — `retry` parameter ignored in the `operation.result(retry=retry)` call · Issue #458 · googleapis/python-api-core

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

retry parameter ignored in the operation.result(retry=retry) call #458

Copy link
Copy link
Closed
Closed
retry parameter ignored in the operation.result(retry=retry) call#458
Copy link
Assignees
vam-google
Labels
priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Description

@medb
medb
opened on Oct 4, 2022
Issue body actions

Environment details

  • OS type and version: Debian 5.18.16
  • Python version: Python 3.10.7
  • pip version: pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)
  • google-api-core version: 2.10.1

Steps to reproduce

  1. Use any GCP API that returns LRO
  2. Use operation.result method call with custom retry parameter
  3. This method will return ~60 seconds after actual operation finishes, while it should not have more than 10 seconds of overhead with custom retry policy (see below)

Code example

from google.api_core import retry
from google.cloud import dataproc_v1
from google.api_core.client_options import ClientOptions

import time

project = '. . .'
region = 'us-central1'

# Create Dataproc batch
client_options = ClientOptions(api_endpoint="{}-dataproc.googleapis.com:443".format(region))
client = dataproc_v1.BatchControllerClient(client_options=client_options)
batch = dataproc_v1.Batch()
batch.spark_batch.main_class = 'org.apache.spark.examples.SparkPi'
batch.spark_batch.jar_file_uris = [
  'file:///usr/lib/spark/examples/jars/spark-examples.jar',
]
batch.spark_batch.args = ['1']
batch.runtime_config.properties = {
  'spark.executor.instances': '2',
}

parent = f"projects/{project}/locations/{region}"
request = dataproc_v1.CreateBatchRequest(
  parent=parent,  # type: ignore
  batch=batch,  # type: ignore
)

# Make the request
print("Creating batch")
operation = client.create_batch(request=request)  # type: ignore
print("Batch created")

# This takes quite a while, waiting on GCP response to resolve
retry = retry.Retry(initial=10, maximum=10, multiplier=1.0, deadline=600)
start = time.time()
response = operation.result(retry=retry)
print("Batch finished")
print(f"Took {time.time() - start} seconds to finish batch job")
print(response)

After replacing response = operation.result(retry=retry) call with custom wait/retry logic operation completion will be detected as expected:

while not operation.done(retry=None):
  time.sleep(10)
response = operation.metadata
Reacted by Anders and Chenyu Li

Activity

  1. medb
    changed the title [-]`retry` parameter ignored in the operation.result(retry=retry) call[/-] [+]`retry` parameter ignored in the `operation.result(retry=retry)` call[/+] on Oct 4, 2022
  2. medb commented on Oct 4, 2022

    @medb
    medb
    on Oct 4, 2022
    Author
    More actions

    I think that this issue is caused by the fact that custom retry passed by caller via kwargs:

    python-api-core/google/api_core/future/polling.py

    Lines 109 to 110 in 4420055

    kwargs = {} if retry is DEFAULT_RETRY else {"retry": retry}
    retry_(self._done_or_raise)(**kwargs)

    But it's not used for actual retries:

    python-api-core/google/api_core/retry.py

    Lines 280 to 282 in 4420055

    sleep_generator = exponential_sleep_generator(
    self._initial, self._maximum, multiplier=self._multiplier
    )

  3. parthea
    added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.
    on Oct 4, 2022
  4. parthea commented on Oct 4, 2022

    @parthea
    parthea
    on Oct 4, 2022
    Contributor
    More actions

    Googlers see internal issue b/248606796

    Reacted by Anders
  5. vam-google
    self-assigned this
    on Oct 4, 2022
  6. vam-google commented on Oct 20, 2022

    @vam-google
    vam-google
    on Oct 20, 2022
    Contributor
    More actions

    This should fix it: #462.

  7. dataders commented on Nov 1, 2022

    @dataders
    dataders
    on Nov 1, 2022
    More actions

    This should fix it: #462.

    @ChenyuLInx have you had a chance to try this fix out yet?

  8. parthea commented on Dec 9, 2022

    @parthea
    parthea
    on Dec 9, 2022
    Contributor
    More actions

    This issue has been fixed in version 2.11.0 and 1.34.0.
    https://github.com/googleapis/python-api-core/releases/tag/v2.11.0
    https://github.com/googleapis/python-api-core/releases/tag/v1.34.0

  9. parthea
    closed this as completedon Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @vam-google
    vam-google

Labels

priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    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.