Skip to content

Commit d8b5263

Browse files
zmk5mhidalgo-raitcappellari-bdai
authored
fixed executor issue using wrong task attribute and implementation call (#198)
Signed-off-by: Zahi Kakish <zmkakis@sandia.gov> Co-authored-by: mhidalgo-rai <144129882+mhidalgo-rai@users.noreply.github.com> Co-authored-by: Tiffany Cappellari <156013635+tcappellari-bdai@users.noreply.github.com>
1 parent 37d5b6a commit d8b5263

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

synchros2/synchros2/executors.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,10 @@ def bind(self, callback_group: rclpy.callback_groups.CallbackGroup, thread_pool:
670670
self._logger.debug(f"Binding {callback_group_name} to thread pool #{thread_pool_index}...")
671671
self._callback_group_affinity[callback_group] = thread_pool
672672

673+
def _spin_once_impl(self, *args: typing.Any, **kwargs: typing.Any) -> None:
674+
"""Spin the executor once (for Jazzy and beyond)."""
675+
self._do_spin_once(*args, **kwargs)
676+
673677
def _do_spin_once(self, *args: typing.Any, **kwargs: typing.Any) -> None:
674678
with self._spin_lock:
675679
try:
@@ -787,9 +791,15 @@ def shutdown(self, timeout_sec: typing.Optional[float] = None) -> bool:
787791
with self._spin_lock:
788792
# rclpy.executors.Executor base implementation leaves tasks
789793
# unawaited upon shutdown. Do the housekeepng.
790-
known_tasks = [
791-
AutoScalingMultiThreadedExecutor.Task(task, entity, node) for task, entity, node in self._tasks
792-
] + list(self._work_in_progress)
794+
if hasattr(self, "_tasks"): # ROS 2 Humble
795+
known_tasks = [
796+
AutoScalingMultiThreadedExecutor.Task(task, entity, node) for task, entity, node in self._tasks
797+
] + list(self._work_in_progress)
798+
else: # ROS 2 Jazzy and beyond
799+
known_tasks = [
800+
AutoScalingMultiThreadedExecutor.Task(task, task_data.source_entity, task_data.source_node)
801+
for task, task_data in self._pending_tasks.items()
802+
] + list(self._work_in_progress)
793803
for task in known_tasks:
794804
task.cancel()
795805
return done

0 commit comments

Comments
 (0)