Skip to content

Commit f71d6d4

Browse files
mergify[bot]nwn
andauthored
Remove duplicate future handling from send_goal_async (#1532) (#1534)
A recent change intended to move this logic into a lock context, but actually ended up duplicating it instead. This fixes that by removing the duplicated logic outside of the lock. It also preserves the explicit typing annotation on the future. (cherry picked from commit 6e22af9) Signed-off-by: Nathan Wiebe Neufeldt <[email protected]> Co-authored-by: Nathan Wiebe Neufeldt <[email protected]>
1 parent b555556 commit f71d6d4

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

rclpy/rclpy/action/client.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ def send_goal_async(
524524
request = self._action_type.Impl.SendGoalService.Request()
525525
request.goal_id = self._generate_random_uuid() if goal_uuid is None else goal_uuid
526526
request.goal = goal
527-
future = Future()
527+
future: Future[ClientGoalHandle[GoalT, ResultT, FeedbackT]] = Future()
528528
with self._lock:
529529
sequence_number = self._client_handle.send_goal_request(request)
530530
if sequence_number in self._pending_goal_requests:
@@ -541,13 +541,6 @@ def send_goal_async(
541541
goal_uuid = bytes(request.goal_id.uuid)
542542
self._feedback_callbacks[goal_uuid] = feedback_callback
543543

544-
future: Future[ClientGoalHandle[GoalT, ResultT, FeedbackT]] = Future()
545-
self._pending_goal_requests[sequence_number] = future
546-
self._goal_sequence_number_to_goal_id[sequence_number] = request.goal_id
547-
future.add_done_callback(self._remove_pending_goal_request)
548-
# Add future so executor is aware
549-
self.add_future(future)
550-
551544
return future
552545

553546
def _cancel_goal(self, goal_handle: ClientGoalHandle[GoalT, ResultT, FeedbackT]

0 commit comments

Comments
 (0)