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

on_attempt callback #89

Open
AlexHill opened this issue Dec 10, 2019 · 1 comment
Open

on_attempt callback #89

AlexHill opened this issue Dec 10, 2019 · 1 comment

Comments

@AlexHill
Copy link

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!

@AlexHill AlexHill changed the title on_retry callback on_retry callback Dec 10, 2019
@AlexHill AlexHill changed the title on_retry callback on_attempt callback Dec 10, 2019
@bgreen-litl
Copy link
Member

I think this is reasonable. I worked up a PR for it here:

#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?

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

2 participants