Skip to content

Commit 7a5ef28

Browse files
author
Marek Piechula
committed
support invalid handle exception from rclpy in the action LoadComposableNodes
Signed-off-by: Marek Piechula <[email protected]>
1 parent 3546016 commit 7a5ef28

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

launch_ros/launch_ros/actions/load_composable_nodes.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
from launch.utilities import perform_substitutions
3939
from launch_ros.parameter_descriptions import ParameterFile
4040

41+
from rclpy.exceptions import InvalidHandle
42+
4143
from .composable_node_container import ComposableNodeContainer
4244

4345
from ..descriptions import ComposableNode
@@ -116,14 +118,24 @@ def _load_node(
116118
:param request: service request to load a node
117119
:param context: current launch context
118120
"""
119-
while not self.__rclpy_load_node_client.wait_for_service(timeout_sec=1.0):
120-
if context.is_shutdown:
121-
self.__logger.warning(
122-
"Abandoning wait for the '{}' service, due to shutdown.".format(
123-
self.__rclpy_load_node_client.srv_name
121+
try:
122+
while not self.__rclpy_load_node_client.wait_for_service(timeout_sec=1.0):
123+
if context.is_shutdown:
124+
self.__logger.warning(
125+
"Abandoning wait for the '{}' service, "
126+
'due to shutdown.'.format(
127+
self.__rclpy_load_node_client.srv_name
128+
)
124129
)
130+
return
131+
except InvalidHandle:
132+
self.__logger.warning(
133+
"Abandoning wait for the '{}' service, "
134+
'due to invalid rclpy handle.'.format(
135+
self.__rclpy_load_node_client.srv_name
125136
)
126-
return
137+
)
138+
return
127139

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

0 commit comments

Comments
 (0)