You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 23, 2026. It is now read-only.
Repository navigation
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
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
Use any GCP API that returns LRO
Use operation.result method call with custom retry parameter
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
fromgoogle.api_coreimportretryfromgoogle.cloudimportdataproc_v1fromgoogle.api_core.client_optionsimportClientOptionsimporttimeproject='. . .'region='us-central1'# Create Dataproc batchclient_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: ignorebatch=batch, # type: ignore
)
# Make the requestprint("Creating batch")
operation=client.create_batch(request=request) # type: ignoreprint("Batch created")
# This takes quite a while, waiting on GCP response to resolveretry=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:
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
Activity
[-]`retry` parameter ignored in the operation.result(retry=retry) call[/-][+]`retry` parameter ignored in the `operation.result(retry=retry)` call[/+]medb commentedon Oct 4, 2022
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
But it's not used for actual retries:
python-api-core/google/api_core/retry.py
Lines 280 to 282 in 4420055
parthea commentedon Oct 4, 2022
Googlers see internal issue b/248606796
vam-google commentedon Oct 20, 2022
This should fix it: #462.
dataders commentedon Nov 1, 2022
@ChenyuLInx have you had a chance to try this fix out yet?
parthea commentedon Dec 9, 2022
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