Skip to content

Commit

Permalink
Fixes spin_until_future_complete inside callback
Browse files Browse the repository at this point in the history
Closes rclpy:#1313
Current if spin_unitl_future_complete is called inside a nodes callback it removes the node from the executor
This results in any subsiquent waitables to never be checked by the node since the node is no longer in the executor
This aims to fix that by only removing the node from the executor if it wasn't already present

Signed-off-by: Jonathan Blixt <[email protected]>
  • Loading branch information
jmblixt3 committed Jul 18, 2024
1 parent 43198cb commit 05f17ee
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions rclpy/rclpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,10 @@ def spin_until_future_complete(
if ``None`` or negative. Don't wait if 0.
"""
executor = get_global_executor() if executor is None else executor
node_added = False
try:
executor.add_node(node)
node_added = executor.add_node(node)
executor.spin_until_future_complete(future, timeout_sec)
finally:
executor.remove_node(node)
if node_added:
executor.remove_node(node)

0 comments on commit 05f17ee

Please sign in to comment.