From c80e8c80f10a769fa98e0df1faab9bd56c3f5a5a Mon Sep 17 00:00:00 2001 From: Hubert Liberacki Date: Thu, 31 Mar 2022 16:58:45 +0200 Subject: [PATCH] Replace deprecated `spin_until_future_complete` with `spin_until_complete` Signed-off-by: Hubert Liberacki --- ros2action/ros2action/verb/send_goal.py | 6 +++--- ros2component/ros2component/api/__init__.py | 6 +++--- ros2lifecycle/ros2lifecycle/api/__init__.py | 6 +++--- ros2param/ros2param/api/__init__.py | 12 ++++++------ ros2param/ros2param/verb/dump.py | 2 +- ros2param/ros2param/verb/list.py | 2 +- ros2service/ros2service/verb/call.py | 2 +- ros2topic/ros2topic/verb/echo.py | 2 +- ros2topic/test/test_echo_pub.py | 14 +++++++------- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/ros2action/ros2action/verb/send_goal.py b/ros2action/ros2action/verb/send_goal.py index 7090ac03e..65de429c3 100644 --- a/ros2action/ros2action/verb/send_goal.py +++ b/ros2action/ros2action/verb/send_goal.py @@ -106,7 +106,7 @@ def send_goal(action_name, action_type, goal_values, feedback_callback): print('Sending goal:\n {}'.format(message_to_yaml(goal))) goal_future = action_client.send_goal_async(goal, feedback_callback) - rclpy.spin_until_future_complete(node, goal_future) + rclpy.spin_until_complete(node, goal_future) goal_handle = goal_future.result() @@ -123,7 +123,7 @@ def send_goal(action_name, action_type, goal_values, feedback_callback): print('Goal accepted with ID: {}\n'.format(bytes(goal_handle.goal_id.uuid).hex())) result_future = goal_handle.get_result_async() - rclpy.spin_until_future_complete(node, result_future) + rclpy.spin_until_complete(node, result_future) result = result_future.result() @@ -143,7 +143,7 @@ def send_goal(action_name, action_type, goal_values, feedback_callback): GoalStatus.STATUS_EXECUTING == goal_handle.status)): print('Canceling goal...') cancel_future = goal_handle.cancel_goal_async() - rclpy.spin_until_future_complete(node, cancel_future) + rclpy.spin_until_complete(node, cancel_future) cancel_response = cancel_future.result() diff --git a/ros2component/ros2component/api/__init__.py b/ros2component/ros2component/api/__init__.py index 171caece1..7af0f4268 100644 --- a/ros2component/ros2component/api/__init__.py +++ b/ros2component/ros2component/api/__init__.py @@ -174,7 +174,7 @@ def _resume(to_completion=False): timer = node.create_timer(timer_period_sec=0.1, callback=resume) try: - rclpy.spin_until_future_complete(node, future, timeout_sec=5.0) + rclpy.spin_until_complete(node, future, timeout_sec=5.0) if not future.done(): resume(to_completion=True) return dict(future.result()) @@ -244,7 +244,7 @@ def load_component_into_container( arg_msg.name = name request.extra_arguments.append(arg_msg) future = load_node_client.call_async(request) - rclpy.spin_until_future_complete(node, future) + rclpy.spin_until_complete(node, future) response = future.result() if not response.success: raise RuntimeError('Failed to load component: ' + response.error_message.capitalize()) @@ -274,7 +274,7 @@ def unload_component_from_container(*, node, remote_container_node_name, compone request = composition_interfaces.srv.UnloadNode.Request() request.unique_id = uid future = unload_node_client.call_async(request) - rclpy.spin_until_future_complete(node, future) + rclpy.spin_until_complete(node, future) response = future.result() yield uid, not response.success, response.error_message finally: diff --git a/ros2lifecycle/ros2lifecycle/api/__init__.py b/ros2lifecycle/ros2lifecycle/api/__init__.py index b1dbb5e91..6e4d216ed 100644 --- a/ros2lifecycle/ros2lifecycle/api/__init__.py +++ b/ros2lifecycle/ros2lifecycle/api/__init__.py @@ -67,7 +67,7 @@ def call_get_states(*, node, node_names): # wait for all responses for future in futures.values(): - rclpy.spin_until_future_complete(node, future) + rclpy.spin_until_complete(node, future) # return current state or exception for each node states = {} @@ -112,7 +112,7 @@ def _call_get_transitions(node, states, service_name): # wait for all responses for future in futures.values(): - rclpy.spin_until_future_complete(node, future) + rclpy.spin_until_complete(node, future) # return transitions from current state or exception for each node transitions = {} @@ -157,7 +157,7 @@ def call_change_states(*, node, transitions): # wait for all responses for future in futures.values(): - rclpy.spin_until_future_complete(node, future) + rclpy.spin_until_complete(node, future) # return success flag or exception for each node results = {} diff --git a/ros2param/ros2param/api/__init__.py b/ros2param/ros2param/api/__init__.py index 9ae41f03e..c328ca999 100644 --- a/ros2param/ros2param/api/__init__.py +++ b/ros2param/ros2param/api/__init__.py @@ -102,8 +102,8 @@ def parse_parameter_dict(*, namespace, parameter_dict): # Unroll nested parameters if type(param_value) == dict: parameters += parse_parameter_dict( - namespace=full_param_name + PARAMETER_SEPARATOR_STRING, - parameter_dict=param_value) + namespace=full_param_name + PARAMETER_SEPARATOR_STRING, + parameter_dict=param_value) else: parameter = Parameter() parameter.name = full_param_name @@ -173,7 +173,7 @@ def call_describe_parameters(*, node, node_name, parameter_names=None): if parameter_names: request.names = parameter_names future = client.call_async(request) - rclpy.spin_until_future_complete(node, future) + rclpy.spin_until_complete(node, future) # handle response response = future.result() @@ -192,7 +192,7 @@ def call_get_parameters(*, node, node_name, parameter_names): request = GetParameters.Request() request.names = parameter_names future = client.call_async(request) - rclpy.spin_until_future_complete(node, future) + rclpy.spin_until_complete(node, future) # handle response response = future.result() @@ -211,7 +211,7 @@ def call_set_parameters(*, node, node_name, parameters): request = SetParameters.Request() request.parameters = parameters future = client.call_async(request) - rclpy.spin_until_future_complete(node, future) + rclpy.spin_until_complete(node, future) # handle response response = future.result() @@ -229,7 +229,7 @@ def call_list_parameters(*, node, node_name, prefix=None): request = ListParameters.Request() future = client.call_async(request) - rclpy.spin_until_future_complete(node, future) + rclpy.spin_until_complete(node, future) # handle response response = future.result() diff --git a/ros2param/ros2param/verb/dump.py b/ros2param/ros2param/verb/dump.py index 98c5b01fe..a3c95f039 100644 --- a/ros2param/ros2param/verb/dump.py +++ b/ros2param/ros2param/verb/dump.py @@ -107,7 +107,7 @@ def main(self, *, args): # noqa: D102 future = client.call_async(request) # wait for response - rclpy.spin_until_future_complete(node, future) + rclpy.spin_until_complete(node, future) yaml_output = {node_name.full_name: {'ros__parameters': {}}} diff --git a/ros2param/ros2param/verb/list.py b/ros2param/ros2param/verb/list.py index 1ba6ee151..0870e910f 100644 --- a/ros2param/ros2param/verb/list.py +++ b/ros2param/ros2param/verb/list.py @@ -103,7 +103,7 @@ def main(self, *, args): # noqa: D102 # wait for all responses for future in futures.values(): - rclpy.spin_until_future_complete(node, future, timeout_sec=1.0) + rclpy.spin_until_complete(node, future, timeout_sec=1.0) # print responses for node_name in sorted(futures.keys()): diff --git a/ros2service/ros2service/verb/call.py b/ros2service/ros2service/verb/call.py index dbf79c04a..cd1f4dfdf 100644 --- a/ros2service/ros2service/verb/call.py +++ b/ros2service/ros2service/verb/call.py @@ -100,7 +100,7 @@ def requester(service_type, service_name, values, period): print('requester: making request: %r\n' % request) last_call = time.time() future = cli.call_async(request) - rclpy.spin_until_future_complete(node, future) + rclpy.spin_until_complete(node, future) if future.result() is not None: print('response:\n%r\n' % future.result()) else: diff --git a/ros2topic/ros2topic/verb/echo.py b/ros2topic/ros2topic/verb/echo.py index bfae04abf..acd66f855 100644 --- a/ros2topic/ros2topic/verb/echo.py +++ b/ros2topic/ros2topic/verb/echo.py @@ -273,7 +273,7 @@ def subscribe_and_spin( raw=raw) if self.future is not None: - rclpy.spin_until_future_complete(node, self.future) + rclpy.spin_until_complete(node, self.future) else: rclpy.spin(node) diff --git a/ros2topic/test/test_echo_pub.py b/ros2topic/test/test_echo_pub.py index f938527ab..7bb497fc8 100644 --- a/ros2topic/test/test_echo_pub.py +++ b/ros2topic/test/test_echo_pub.py @@ -42,8 +42,8 @@ # https://github.com/ros2/build_farmer/issues/248 if sys.platform.startswith('win'): pytest.skip( - 'CLI tests can block for a pathological amount of time on Windows.', - allow_module_level=True) + 'CLI tests can block for a pathological amount of time on Windows.', + allow_module_level=True) TEST_NODE = 'cli_echo_pub_test_node' @@ -160,7 +160,7 @@ def message_callback(msg): filtered_rmw_implementation=get_rmw_implementation_identifier() ) ) as command: - self.executor.spin_until_future_complete(future, timeout_sec=10) + self.executor.spin_until_complete(future, timeout_sec=10) command.wait_for_shutdown(timeout=10) # Check results @@ -275,7 +275,7 @@ def publish_message(): ) ) as command: # The future won't complete - we will hit the timeout - self.executor.spin_until_future_complete( + self.executor.spin_until_complete( rclpy.task.Future(), timeout_sec=5 ) command.wait_for_shutdown(timeout=10) @@ -333,7 +333,7 @@ def publish_message(): ) ) as command: # The future won't complete - we will hit the timeout - self.executor.spin_until_future_complete( + self.executor.spin_until_complete( rclpy.task.Future(), timeout_sec=5 ) command.wait_for_shutdown(timeout=10) @@ -374,7 +374,7 @@ def publish_message(): ) ) as command: # The future won't complete - we will hit the timeout - self.executor.spin_until_future_complete( + self.executor.spin_until_complete( rclpy.task.Future(), timeout_sec=5 ) assert command.wait_for_output(functools.partial( @@ -416,7 +416,7 @@ def publish_message(): ) ) as command: # The future won't complete - we will hit the timeout - self.executor.spin_until_future_complete( + self.executor.spin_until_complete( rclpy.task.Future(), timeout_sec=3 ) assert command.wait_for_shutdown(timeout=5)