What I mean is, change original code from
if cleanup:
cleanup()
if n == attempts:
log.info("retry: Giving up on %s", action_name)
raise
to
if n == attempts:
log.info("retry: Giving up on %s", action_name)
raise
if cleanup:
cleanup()
Two benefits of this change:
- The cleanup may be costly. Doing cleanup without more attempts is a waste.
- If the last attempt failed, it is better to keep the environment as-is for developer investigation. Cleanup may be destructive and make debugging harder.
For original behavior (do something after exception), it could be done inside action() using normal try..except.
How do you think? If you think it is good change, I can send PR.
What I mean is, change original code from
to
Two benefits of this change:
For original behavior (do something after exception), it could be done inside action() using normal try..except.
How do you think? If you think it is good change, I can send PR.