Skip to content

Conversation

@tseaver
Copy link
Contributor

@tseaver tseaver commented Aug 28, 2017

Permit application code to reset / fix-up state before retrying.

See: #3889

Permit application code to reset / fix-up state before retrying.

See:
#3889
@tseaver tseaver requested a review from theacodes August 28, 2017 20:49
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Aug 28, 2017
Copy link
Contributor

@dhermes dhermes left a comment

Choose a reason for hiding this comment

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

LGTM though I think you should let @jonparrott have a look before merging

sleep_generator (Iterator[float]): An infinite iterator that determines
how long to sleep between retries.
deadline (float): How long to keep retrying the target.
on_error(Callable): A function to call while processing a retryable

This comment was marked as spam.

This comment was marked as spam.

Args:
func (Callable): The callable to add retry behavior to.
on_error(Callable): A function to call while processing a

This comment was marked as spam.

This comment was marked as spam.

raise ValueError()
return 42

result = retry.retry_target(

This comment was marked as spam.


result = retry.retry_target(
target, predicate, range(10), None, on_error=on_error)

This comment was marked as spam.

This comment was marked as spam.

Copy link
Contributor

@theacodes theacodes left a comment

Choose a reason for hiding this comment

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

looks mostly good, just a few questions.

raise
last_exc = exc
if on_error is not None:
on_error()

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

sleep_generator (Iterator[float]): An infinite iterator that determines
how long to sleep between retries.
deadline (float): How long to keep retrying the target.
on_error(Callable): A function to call while processing a retryable

This comment was marked as spam.

This comment was marked as spam.

self._deadline = deadline

def __call__(self, func):
def __call__(self, func, on_error=None):

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@theacodes
Copy link
Contributor

This is fine to merge once on_error is passed the exc. Then, @tseaver can use it to make #3889 much simpler.

@tseaver tseaver merged commit 9c4144b into googleapis:master Aug 29, 2017
@tseaver tseaver deleted the core-retry_target-add-on_error-argument branch August 29, 2017 14:33
parthea pushed a commit that referenced this pull request Nov 24, 2025
Permit application code to reset / fix-up state before retrying.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: core cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants