-
Notifications
You must be signed in to change notification settings - Fork 262
[rclpy] Fix spin_once() removing node from executor even if already attached #1446
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
Conversation
… attached Signed-off-by: Alon <[email protected]>
64b7cac to
7e848c4
Compare
|
Signed-off-by added via rebase. Ready for review! |
|
Pulls: #1446 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am not opposed to have this fix in general, because we already have the similar fix with #1316.
But I do not think this PR fixes the issue reported on #1445, because MultiThreadedExecutor is still going to be removed in ths 1st spin_once. IMO, this PR or #1316 only works if the application uses get_global_executor to avoid removing the executor.
Note: i mean that the application needs to add executor argument to spin_once.
can you explain what problem are you trying to address here?
|
Hi @fujitatomoya, I originally encountered this unexpected behavior in pymoveit, where calling spin_once caused the executor to lose its node. This fix, combined with explicitly passing the executor to spin_once, allows it to function as expected in that context. Hope this clears things up — please let me know if anything else is needed. Thanks again, |
|
@alonborn thanks for the comment. yeah, for doing resolve the original issue, we need to use executor optional argument with this PR. |
|
Note to keep the consistency with #1316, we need to backport this to all downstream distros. |
|
@Mergifyio backport kilted jazzy humble |
✅ Backports have been created
|
… attached (#1446) Signed-off-by: Alon <[email protected]> (cherry picked from commit 3414456)
… attached (#1446) Signed-off-by: Alon <[email protected]> (cherry picked from commit 3414456)
… attached (#1446) Signed-off-by: Alon <[email protected]> (cherry picked from commit 3414456)
… attached (#1446) (#1450) (cherry picked from commit 3414456) Signed-off-by: Alon <[email protected]> Co-authored-by: Alon Borenshtein <[email protected]>
… attached (#1446) (#1449) (cherry picked from commit 3414456) Signed-off-by: Alon <[email protected]> Co-authored-by: Alon Borenshtein <[email protected]>
… attached (#1446) (#1451) (cherry picked from commit 3414456) Signed-off-by: Alon <[email protected]> Co-authored-by: Alon Borenshtein <[email protected]>
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 calledexecutor.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 inspin_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
rclpyutilities more consistent.Related Issue
It handles a similar issue like #1316