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

Pass exceptions to the cleanup method #40

Open
fredfortier opened this issue Jan 2, 2018 · 0 comments
Open

Pass exceptions to the cleanup method #40

fredfortier opened this issue Jan 2, 2018 · 0 comments

Comments

@fredfortier
Copy link

fredfortier commented Jan 2, 2018

I'd like to see what's happening in the logs when a retry is necessary. The cleanup function is nice but I'd like to access the exception object in order to print it in my warning message. I understand that I can puttry...except inside on my foo function but I like the conciseness of letting redo deal with the inner exceptions.

        bar = retry(
            action=foo,
            attempts=5,
            sleeptime=5,
            retry_exceptions=(MyCustomError,),
            cleanup=lambda: log.warn('Trying the operation again. But why did it fail?'))
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

1 participant