Skip to content

Add google.api.core.retry.Retry decorator - #3835

Merged
theacodes merged 7 commits into
googleapis:masterfrom
theacodes:api-core-retry-decorator
Aug 17, 2017
Merged

Add google.api.core.retry.Retry decorator#3835
theacodes merged 7 commits into
googleapis:masterfrom
theacodes:api-core-retry-decorator

Conversation

@theacodes

Copy link
Copy Markdown
Contributor

No description provided.

@googlebotgooglebot added the cla: yes This human has signed the Contributor License Agreement. label Aug 17, 2017

@dhermesdhermes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Mostly LGTM (thanks for keeping this PR small)

Comment threadcore/google/api/core/retry.py Outdated
"""Helpers for retrying functions with exponential back-off."""
"""Helpers for retrying functions with exponential back-off.

The :cls`Retry` decorator can be used to retry function that raise exceptions

This comment was marked as spam.

This comment was marked as spam.

Comment threadcore/google/api/core/retry.py Outdated
predicate (Callable[Exception]): A callable that should return ``True``
if the given exception is retryable.
initial (float): The minimum about of time to delay. This must
be greater than 0.

This comment was marked as spam.

This comment was marked as spam.

Comment threadcore/google/api/core/retry.py Outdated
predicate=if_transient_error,
initial=1,
maximum=60,
multiplier=2,

This comment was marked as spam.

This comment was marked as spam.

Comment threadcore/google/api/core/retry.py Outdated
maximum (float): The maximum about of time to delay.
multiplier (float): The multiplier applied to the delay.
jitter (float): The maximum about of randomness to apply to the delay.
deadline (float): How long to keep retrying.

This comment was marked as spam.

This comment was marked as spam.

Comment threadcore/google/api/core/retry.py Outdated
be greater than 0.
maximum (float): The maximum about of time to delay.
multiplier (float): The multiplier applied to the delay.
jitter (float): The maximum about of randomness to apply to the delay.

This comment was marked as spam.

This comment was marked as spam.

"""
return Retry(
predicate=self._predicate,
initial=initial if initial is not None else self._initial,

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

Comment threadcore/google/api/core/retry.py Outdated
'<Retry predicate={}, initial={:.1f}, maximum={:.1f}, '
'multiplier={:.1f}, jitter={:.1f}, deadline={:.1f}>'.format(
self._predicate, self._initial, self._maximum,
self._multiplier, self._jitter, self._deadline))

This comment was marked as spam.

This comment was marked as spam.

@dhermes

Copy link
Copy Markdown
Contributor

LGTM

Comment threadcore/google/api/core/retry.py Outdated
"""Helpers for retrying functions with exponential back-off."""
"""Helpers for retrying functions with exponential back-off.

The :cls`Retry` decorator can be used to retry functions that raise exceptions

This comment was marked as spam.

Comment threadcore/google/api/core/retry.py Outdated
maximum (float): The maximum about of time to delay.
multiplier (float): The multiplier applied to the delay.
jitter (float): The maximum about of randomness to apply to the delay.
max_jitter (float): The maximum about of randomness to apply to the

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

Comment threadcore/google/api/core/retry.py Outdated
return retry_wrapped_func

def with_deadline(self, deadline):
"""Returns a copy of this retry with the given deadline.

This comment was marked as spam.

This comment was marked as spam.

@lukesneeringerlukesneeringer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks fine. Only putting "comment" since in Hangouts, @jonparrott suggested he does plan on changing the jitter algorithm.

If you end up deciding to leave it, then LGTM. If you end up deciding to change, it I will re-review once you have.

@theacodes
theacodes merged commit 36304f7 into googleapis:masterAug 17, 2017
@theacodes
theacodes deleted the api-core-retry-decorator branch August 17, 2017 22:34
landrito pushed a commit to landrito/google-cloud-python that referenced this pull request Aug 21, 2017
* Add google.api.core.retry.Retry decorator
* Add futures dependency
* Change jitter algorithm
landrito pushed a commit to landrito/google-cloud-python that referenced this pull request Aug 22, 2017
* Add google.api.core.retry.Retry decorator
* Add futures dependency
* Change jitter algorithm
landrito pushed a commit to landrito/google-cloud-python that referenced this pull request Aug 22, 2017
* Add google.api.core.retry.Retry decorator
* Add futures dependency
* Change jitter algorithm
parthea pushed a commit that referenced this pull request Nov 24, 2025
* Add google.api.core.retry.Retry decorator
* Add futures dependency
* Change jitter algorithm
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: corecla: yesThis human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@theacodes@dhermes@lukesneeringer@googlebot