-
Notifications
You must be signed in to change notification settings - Fork 812
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
[windows] record restarts on a specific timeframe #1664
Conversation
def restart(self): | ||
self._count_restarts += 1 | ||
if self._count_restarts >= self._MAX_RESTARTS: | ||
if not self._can_restart(): | ||
servicemanager.LogInfoMsg( | ||
"%s reached the limit of restarts. Not restarting..." % self._name) |
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.
To ease a potential debug, could you add the number of restarts (or tries), max number of restarts, and maybe the time window ?
So something like:
"{0} reached the limit of restarts ({1} tries during the last {3}s (max authorized: {2})). Not restarting...".format(self._name, len(self._restarts), self._restarts[0] - time.time()) ?
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.
Good idea, thanks.
1cbaf83
to
203e6ea
Compare
self._name = name | ||
self._process = process | ||
self._count_restarts = 0 | ||
self._restarts = deque([]) | ||
self._MAX_RESTARTS = max_restarts |
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 don't really like this way (not your PR, but close), having a "dynamic" constant. Maybe you could instead have a DEFAULT_MAX_RESTARTS = 5
, max_restarts=None
, and self._max_restarts = max_restarts or self.DEFAULT_MAX_RESTARTS
: what do you think ?
Nice improvement! |
Drop the global count of restarts in favor of a timeframe based one.
203e6ea
to
49f7cb3
Compare
[windows] record restarts on a specific timeframe
Drop the global count of restarts in favor of a timeframe based one.