mozilla-releng/redo

Pass exceptions to the `cleanup` method

Opened this issue · 0 comments

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?'))