diff --git a/launch_testing_ros/launch_testing_ros/wait_for_topics.py b/launch_testing_ros/launch_testing_ros/wait_for_topics.py index 5cf2c9cf..8e99423d 100644 --- a/launch_testing_ros/launch_testing_ros/wait_for_topics.py +++ b/launch_testing_ros/launch_testing_ros/wait_for_topics.py @@ -63,9 +63,15 @@ def __init__(self, topic_tuples, timeout=5.0, messages_received_buffer_length=10 self._prepare_ros_node() # Start spinning - self.__ros_spin_thread = Thread(target=self.__ros_executor.spin) + self.__ros_spin_thread = Thread(target=self._spin_handle_external_shutdown) self.__ros_spin_thread.start() + def _spin_handle_external_shutdown(self): + try: + self.__ros_executor.spin() + except rclpy.executors.ExternalShutdownException: + pass + def _prepare_ros_node(self): node_name = '_test_node_' + ''.join( random.choices(string.ascii_uppercase + string.digits, k=10)