-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add maxbackoff and backoffincrement options #1626
base: main
Are you sure you want to change the base?
Conversation
* maxbackoff - the maximum number of seconds that supervisor will backoff before restart * backoffincrement - the number of seconds to add to the backoff after each retry
If maxbackoff and backoffincrement are both set, adding backoffincrement to backoff may result in the remaining retries having a backoff value higher than maxbackoff. Ex: backoff will go from |
@@ -168,7 +168,8 @@ def change_state(self, new_state, expected=True): | |||
self.state = new_state | |||
if new_state == ProcessStates.BACKOFF: | |||
now = time.time() | |||
self.backoff += 1 | |||
if self.backoff < self.config.maxbackoff or self.config.maxbackoff == 0: | |||
self.backoff += self.config.backoffincrement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cdelguercio to prevent the issue you mentioned in #1626 (comment) you can use min
:
self.backoff = min(self.backoff + self.config.backoffincrement, self.config.maxbackoff)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you'd have to do something like:
self.backoff = self.config.maxbackoff == 0 ? self.backoff + self.config.backoffincrement : min(self.backoff + self.config.backoffincrement, self.config.maxbackoff);
The question is: what's preferred?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I see what you are saying, I missed the self.config.maxbackoff == 0
case.
What you have suggested looks correct 👍
maxbackoff - the maximum number of seconds that supervisor will backoff before restart
backoffincrement - the number of seconds to add to the backoff after each retry
based on #1529
Fixes #323