-
Notifications
You must be signed in to change notification settings - Fork 49
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
Check safety during transition #518
Check safety during transition #518
Conversation
If the state doesn't successfully change, check the safety between each iteration and if False send to parking Note: no test for this written
Codecov Report
@@ Coverage Diff @@
## develop #518 +/- ##
===========================================
- Coverage 70.46% 70.33% -0.14%
===========================================
Files 62 62
Lines 5418 5423 +5
Branches 752 753 +1
===========================================
- Hits 3818 3814 -4
- Misses 1392 1401 +9
Partials 208 208
Continue to review full report at Codecov.
|
pocs/state/machine.py
Outdated
@@ -137,7 +137,9 @@ def run(self, exit_when_done=False, run_once=False): | |||
|
|||
# If we didn't successfully transition, sleep a while then try again | |||
if not state_changed: | |||
if _loop_iteration > 5: | |||
if self.is_safe() is False: |
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.
Let's add logging to indicate what is going on. For example:
if not state_changed:
self.logger.warning("Failed to transition from {} to {}", self.state, self.next_state)
if not self.is_safe():
self.logger.warning("Conditions have become unsafe; setting next state to 'parking'")
self.next_state = 'parking'
elif _loop_iteration > 5:
self.logger.warning("Stuck in current state for 5 iterations, parking")
self.next_state = 'parking'
else:
_loop_iteration = _loop_iteration + 1
self.logger.warning("Sleeping for a bit, then trying the transition again (loop: {})",
_loop_iteration)
self.sleep(with_status=False)
…eather-while-transition-504
If the state doesn't successfully change, check the safety between each iteration and if False send to parking
Note: still trying to figure out how to test this
Fixes #504