Skip to content

Commit

Permalink
Replace deprecated spin_until_future_complete with `spin_until_comp…
Browse files Browse the repository at this point in the history
…lete`

Signed-off-by: Hubert Liberacki <[email protected]>
  • Loading branch information
hliberacki committed Apr 2, 2022
1 parent 770bb42 commit c80e8c8
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 26 deletions.
6 changes: 3 additions & 3 deletions ros2action/ros2action/verb/send_goal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

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

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

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
12 changes: 6 additions & 6 deletions ros2param/ros2param/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion ros2param/ros2param/verb/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': {}}}

Expand Down
2 changes: 1 addition & 1 deletion ros2param/ros2param/verb/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()):
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 @@ -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:
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 @@ -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)

Expand Down
14 changes: 7 additions & 7 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 @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c80e8c8

Please sign in to comment.