on_attempt callback
It would be useful to have an on_attempt callback which was called before every invocation of the decorated function - seems like that would complete the callback suite :)
My use-case is updating some state (i.e. "connecting" / "waiting" / "connected") that it's not practical to modify from inside my decorated function. if I wasn't using backoff, I would update the state immediately before and after calling my connect function.
I can make a PR if there's support for this idea!
I think this is reasonable. I worked up a PR for it here:
https://github.com/litl/backoff/pull/90
I think to be consistent with other names like max_tries and tries we should probably call it on_try. (I think I might like the name on_attempt better for what it's worth.)
The PR above still needs a little love before I'd be ready to merge but if you want to test it out in the meantime, please do.
I'm also a bit curious about the use case you mentioned. Do you have a code sample of it? Do you think it is something that would be worth adding as an example to the backoff docs?