Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated spin_until_future_complete #893

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ros2action/ros2action/verb/send_goal.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,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()

Expand All @@ -134,7 +134,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()

Expand All @@ -154,7 +154,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()

Expand Down
6 changes: 3 additions & 3 deletions ros2component/ros2component/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions ros2lifecycle/ros2lifecycle/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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 = {}
Expand Down
10 changes: 5 additions & 5 deletions ros2param/ros2param/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def load_parameter_file(*, node, node_name, parameter_file, use_wildcard):
f'parameter services for node {node_name}')
future = client.load_parameter_file(parameter_file, use_wildcard)
parameters = list(parameter_dict_from_yaml_file(parameter_file, use_wildcard).values())
rclpy.spin_until_future_complete(node, future)
rclpy.spin_until_complete(node, future)
response = future.result()
assert len(response.results) == len(parameters), 'Not all parameters set'
for i in range(0, len(response.results)):
Expand All @@ -65,7 +65,7 @@ def call_describe_parameters(*, node, node_name, parameter_names=None):
raise RuntimeError('Wait for service timed out waiting for '
f'parameter services for node {node_name}')
future = client.describe_parameters(parameter_names)
rclpy.spin_until_future_complete(node, future)
rclpy.spin_until_complete(node, future)
response = future.result()
if response is None:
raise RuntimeError('Exception while calling service of node '
Expand All @@ -80,7 +80,7 @@ def call_get_parameters(*, node, node_name, parameter_names):
raise RuntimeError('Wait for service timed out waiting for '
f'parameter services for node {node_name}')
future = client.get_parameters(parameter_names)
rclpy.spin_until_future_complete(node, future)
rclpy.spin_until_complete(node, future)
response = future.result()
if response is None:
raise RuntimeError('Exception while calling service of node '
Expand All @@ -95,7 +95,7 @@ def call_set_parameters(*, node, node_name, parameters):
raise RuntimeError('Wait for service timed out waiting for '
f'parameter services for node {node_name}')
future = client.set_parameters(parameters)
rclpy.spin_until_future_complete(node, future)
rclpy.spin_until_complete(node, future)
response = future.result()
if response is None:
raise RuntimeError('Exception while calling service of node '
Expand All @@ -109,7 +109,7 @@ def call_list_parameters(*, node, node_name, prefixes=None):
if not ready:
return None
future = client.list_parameters(prefixes=prefixes)
rclpy.spin_until_future_complete(node, future)
rclpy.spin_until_complete(node, future)
return future


Expand Down
2 changes: 1 addition & 1 deletion ros2service/ros2service/verb/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,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:
Expand Down
2 changes: 1 addition & 1 deletion ros2topic/ros2topic/verb/echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,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)

Expand Down
16 changes: 8 additions & 8 deletions ros2topic/test/test_echo_pub.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -254,7 +254,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)
assert future.done()
assert command.wait_for_shutdown(timeout=20)

Expand Down Expand Up @@ -356,7 +356,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)
Expand Down Expand Up @@ -414,7 +414,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)
Expand Down Expand Up @@ -455,7 +455,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(
Expand Down Expand Up @@ -497,7 +497,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)
Expand Down
6 changes: 3 additions & 3 deletions ros2topic/test/test_use_sim_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def test_pub_times(self, launch_service, proc_info, proc_output):
)
) as command:
# The process will end up in around 2.5s (here we set 3s)
self.executor.spin_until_future_complete(
self.executor.spin_until_complete(
rclpy.task.Future(), timeout_sec=3
)
assert command.wait_for_shutdown(timeout=5)
Expand Down Expand Up @@ -183,7 +183,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(
Expand Down Expand Up @@ -240,7 +240,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=10
)
assert command.wait_for_output(functools.partial(
Expand Down