Skip to content

Commit

Permalink
fix race condition reseting a default controller
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Nov 14, 2016
1 parent e15580c commit a4ce8fc
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions malcolm/parts/builtin/childpart.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ def store_params(self, params):

@ManagerController.Reset
def reset(self, task):
# Wait until we have finished resetting
state = self.child.state
if state == sm.RESETTING:
task.when_matches(self.child["state"], sm.READY)
elif state != sm.READY:
# Wait until we are READY
try:
task.post(self.child["reset"])
except ValueError:
# We get a "ValueError: child is not writeable" if we can't run
# reset, probably because the child is already resetting,
# so just wait for it to be ready
task.when_matches(
self.child["state"], sm.READY, bad_values=[sm.FAULT])


@ManagerController.ReportOutports
def pre_layout(self, _):
Expand Down

0 comments on commit a4ce8fc

Please sign in to comment.