Skip to content
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

Add graceful shutdown #794

Merged
merged 2 commits into from
Oct 4, 2022
Merged

Conversation

achim-k
Copy link
Contributor

@achim-k achim-k commented Oct 4, 2022

Public API Changes
None

Description
This patch adds graceful shutdown for the rosapi/rosapi_node and rosbridge_server/rosbridge_websocket.py nodes when a SIGINT is recieved (e.g. via ctrl+c). rclpy by default adds an sigint handler which takes care of the shutdown already.

Without this patch, the following exception logs are printed:

[rosbridge_websocket-1] Traceback (most recent call last):
[rosbridge_websocket-1]   File "/opt/ros2_ws/install/rosbridge_server/lib/rosbridge_server/rosbridge_websocket", line 343, in <module>
[rosbridge_websocket-1]     main()
[rosbridge_websocket-1]   File "/opt/ros2_ws/install/rosbridge_server/lib/rosbridge_server/rosbridge_websocket", line 338, in main
[rosbridge_websocket-1]     rclpy.shutdown()
[rosbridge_websocket-1]   File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/__init__.py", line 126, in shutdown
[rosbridge_websocket-1]     _shutdown(context=context)
[rosbridge_websocket-1]   File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/utilities.py", line 58, in shutdown
[rosbridge_websocket-1]     return context.shutdown()
[rosbridge_websocket-1]   File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/context.py", line 102, in shutdown
[rosbridge_websocket-1]     self.__context.shutdown()
[rosbridge_websocket-1] rclpy._rclpy_pybind11.RCLError: failed to shutdown: rcl_shutdown already called on the given context, at ./src/rcl/init.c:241
[rosapi_node-2] [INFO] [1664897157.258284532] [rosapi]: Exiting due to SIGINT
[rosapi_node-2] Failed to publish log message to rosout: publisher's context is invalid, at ./src/rcl/publisher.c:389
[rosapi_node-2] Traceback (most recent call last):
[rosapi_node-2]   File "/opt/ros2_ws/install/rosapi/lib/rosapi/rosapi_node", line 330, in <module>
[rosapi_node-2]     main()
[rosapi_node-2]   File "/opt/ros2_ws/install/rosapi/lib/rosapi/rosapi_node", line 326, in main
[rosapi_node-2]     rclpy.shutdown()
[rosapi_node-2]   File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/__init__.py", line 126, in shutdown
[rosapi_node-2]     _shutdown(context=context)
[rosapi_node-2]   File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/utilities.py", line 58, in shutdown
[rosapi_node-2]     return context.shutdown()
[rosapi_node-2]   File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/context.py", line 102, in shutdown
[rosapi_node-2]     self.__context.shutdown()
[rosapi_node-2] rclpy._rclpy_pybind11.RCLError: failed to shutdown: rcl_shutdown already called on the given context, at ./src/rcl/init.c:241

@achim-k achim-k merged commit 9c5d344 into RobotWebTools:ros2 Oct 4, 2022
@achim-k achim-k deleted the graceful_shutdown branch October 4, 2022 23:01
jihoonl pushed a commit to floatic-unicorn/rosbridge_suite that referenced this pull request Oct 6, 2022
* rosapi: Make shutdown more graceful.

* rosbridge_server: Make shutdown more graceful.
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.

None yet

2 participants