Skip to content

Commit 3fc2a89

Browse files
ayonixAdrian Leva
authored andcommitted
Iterate over the handlerinstances of the handlersubsystem. Fixes #90
1 parent b6cd72d commit 3fc2a89

1 file changed

Lines changed: 5 additions & 17 deletions

File tree

src/lib/execute.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -154,24 +154,12 @@ def shutdown(self):
154154
self.runStrategy.clear()
155155
logging.info("QUITTING.")
156156

157-
all_handler_types = ['init', 'pose', 'locomotionCommand', 'drive', 'motionControl', 'sensor', 'actuator']
158-
159-
for htype in all_handler_types:
160-
logging.info("Terminating {} handler...".format(htype))
161-
if htype in self.proj.h_instance:
162-
if isinstance(self.proj.h_instance[htype], dict):
163-
handlers = [v for k,v in self.proj.h_instance[htype].iteritems()]
164-
else:
165-
handlers = [self.proj.h_instance[htype]]
166-
167-
for h in handlers:
168-
if hasattr(h, "_stop"):
169-
logging.debug("Calling _stop() on {}".format(h.__class__.__name__))
170-
h._stop()
171-
else:
172-
logging.debug("{} does not have _stop() function".format(h.__class__.__name__))
157+
for h in self.hsub.handler_instance:
158+
if hasattr(h, "_stop"):
159+
logging.debug("Calling _stop() on {}".format(h.__class__.__name__))
160+
h._stop()
173161
else:
174-
logging.debug("{} handler not found in h_instance".format(htype))
162+
logging.debug("{} does not have _stop() function".format(h.__class__.__name__))
175163

176164
self.alive.clear()
177165

0 commit comments

Comments
 (0)