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

Discussion: Retry hook for logging or other #11

Closed
bodenr opened this issue Aug 17, 2016 · 1 comment
Closed

Discussion: Retry hook for logging or other #11

bodenr opened this issue Aug 17, 2016 · 1 comment

Comments

@bodenr
Copy link
Contributor

bodenr commented Aug 17, 2016

One of the PRs I had on retrying [1] was to support a generic wait hook, suitable for logging or other per-retry operations.

I was looking at tenacity and wanted to confirm how I'd do this:

def logged_wait(*args, **kwargs):
    # no-op wait just to log on each attempt
    print("Yet another logged attempt")
    return 0


@retry(wait=wait_combine(logged_wait, wait_fixed(1000)), ...)
def my_retried_func():
    # interesting retryable stuff here

Is this about right?

[1] rholder/retrying#50

@jd
Copy link
Owner

jd commented Aug 17, 2016

@bodenr yeah, that should totally work. You can also use after_attempts and before_attempts if that suits you.

@jd jd closed this as completed Aug 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants