Skip to content

Fix a bug when using multiple rclpy.init context managers. #1314

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

Merged
merged 1 commit into from
Jul 22, 2024

Conversation

clalancette
Copy link
Contributor

That is, if you call rclpy.init as a context manager within the same process, and using the default context, it currently fails. That is because you cannot reinitialize (call init) on a Context object once it has been shutdown. Instead, force try_shutdown to replace the global context object with a new one on rclpy.init shutdown by passing a None.

This should fix some failing tests on the repeated jobs, like https://ci.ros2.org/view/nightly/job/nightly_linux_repeated/3516/testReport/junit/test_launch_ros.test.test_launch_ros.actions/test_ros_timer/test_timer_uses_sim_time_2_3_/

@Crola1702 FYI

That is, if you call rclpy.init as a context manager within
the same process, and using the default context, it currently
fails.  That is because you cannot reinitialize (call init) on
a Context object once it has been shutdown.  Instead, force
try_shutdown to replace the global context object with a new
one on rclpy.init shutdown by passing a None.

Signed-off-by: Chris Lalancette <[email protected]>
@clalancette
Copy link
Contributor Author

CI:

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

@fujitatomoya
Copy link
Collaborator

@clalancette can you check windows failure? seems unrelated to me.

@clalancette
Copy link
Contributor Author

@clalancette can you check windows failure? seems unrelated to me.

Yeah, it is unrelated, and it's a known flake.

Going ahead and merging this one, thanks for the reviews!

@clalancette clalancette merged commit f7dd807 into rolling Jul 22, 2024
3 checks passed
@clalancette clalancette deleted the clalancette/fix-multiple-rclpy-init branch July 22, 2024 11:49
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.

4 participants