Skip to content

Conversation

@mergify
Copy link
Contributor

@mergify mergify bot commented Apr 29, 2025

Summary

This pull request fixes a bug where rclpy.spin_once() would remove a node from its executor that it didn't add.

Previously, spin_once() unconditionally called executor.remove_node(node) at the end, disconnecting nodes managed by user-created executors (e.g., MultiThreadedExecutor).

This fix tracks whether spin_once() itself added the node, and only removes it if necessary — matching the behavior already used in spin_until_future_complete().


Motivation

Calling rclpy.spin_once() on a node that is part of an existing executor (e.g., for asynchronous callbacks) currently breaks the executor's management, causing nodes to silently stop working.

This fix ensures better safety and makes rclpy utilities more consistent.


Related Issue

It handles a similar issue like #1316



This is an automatic backport of pull request #1446 done by [Mergify](https://mergify.com).

@fujitatomoya
Copy link
Collaborator

Pulls: #1450
Gist: https://gist.githubusercontent.com/fujitatomoya/a19dad7c9d07148fb31f6e206f51a60b/raw/7cb65ddeb640380c5fed50b5b7a8c1eab27aded8/ros2.repos
BUILD args: --packages-above-and-dependencies rclpy
TEST args: --packages-above rclpy
ROS Distro: jazzy
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/15834

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@fujitatomoya fujitatomoya merged commit 797e5eb into jazzy May 9, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants