Skip to content

Pass exceptions to the cleanup method #40

@fredfortier

Description

@fredfortier

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions