Skip to content

Commit

Permalink
Iterate over the handlerinstances of the handlersubsystem. Fixes #90
Browse files Browse the repository at this point in the history
  • Loading branch information
ayonix authored and Adrian Leva committed Oct 11, 2016
1 parent b6cd72d commit 3fc2a89
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions src/lib/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,24 +154,12 @@ def shutdown(self):
self.runStrategy.clear()
logging.info("QUITTING.")

all_handler_types = ['init', 'pose', 'locomotionCommand', 'drive', 'motionControl', 'sensor', 'actuator']

for htype in all_handler_types:
logging.info("Terminating {} handler...".format(htype))
if htype in self.proj.h_instance:
if isinstance(self.proj.h_instance[htype], dict):
handlers = [v for k,v in self.proj.h_instance[htype].iteritems()]
else:
handlers = [self.proj.h_instance[htype]]

for h in handlers:
if hasattr(h, "_stop"):
logging.debug("Calling _stop() on {}".format(h.__class__.__name__))
h._stop()
else:
logging.debug("{} does not have _stop() function".format(h.__class__.__name__))
for h in self.hsub.handler_instance:
if hasattr(h, "_stop"):
logging.debug("Calling _stop() on {}".format(h.__class__.__name__))
h._stop()
else:
logging.debug("{} handler not found in h_instance".format(htype))
logging.debug("{} does not have _stop() function".format(h.__class__.__name__))

self.alive.clear()

Expand Down

0 comments on commit 3fc2a89

Please sign in to comment.