Skip to content

Commit

Permalink
support invalid handle exception from rclpy in the action LoadComposa…
Browse files Browse the repository at this point in the history
…bleNodes

Signed-off-by: Marek Piechula <[email protected]>
  • Loading branch information
Marek Piechula committed Feb 2, 2024
1 parent 3546016 commit 7a5ef28
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions launch_ros/launch_ros/actions/load_composable_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
from launch.utilities import perform_substitutions
from launch_ros.parameter_descriptions import ParameterFile

from rclpy.exceptions import InvalidHandle

from .composable_node_container import ComposableNodeContainer

from ..descriptions import ComposableNode
Expand Down Expand Up @@ -116,14 +118,24 @@ def _load_node(
:param request: service request to load a node
:param context: current launch context
"""
while not self.__rclpy_load_node_client.wait_for_service(timeout_sec=1.0):
if context.is_shutdown:
self.__logger.warning(
"Abandoning wait for the '{}' service, due to shutdown.".format(
self.__rclpy_load_node_client.srv_name
try:
while not self.__rclpy_load_node_client.wait_for_service(timeout_sec=1.0):
if context.is_shutdown:
self.__logger.warning(
"Abandoning wait for the '{}' service, "
'due to shutdown.'.format(
self.__rclpy_load_node_client.srv_name
)
)
return
except InvalidHandle:
self.__logger.warning(
"Abandoning wait for the '{}' service, "
'due to invalid rclpy handle.'.format(
self.__rclpy_load_node_client.srv_name
)
return
)
return

# Asynchronously wait on service call so that we can periodically check for shutdown
event = threading.Event()
Expand Down

0 comments on commit 7a5ef28

Please sign in to comment.