ros2 / ros2cli

ROS 2 command line interface tools
Apache License 2.0
173 stars 159 forks source link

Shutdown ros2doctor hello when ctrl-c is received #826

Closed mjcarroll closed 1 year ago

mjcarroll commented 1 year ago

Uncovered in tutorial party: https://github.com/osrf/ros2_test_cases/issues/548

There was an issue where ros2 doctor hello would not shutdown on Windows, instead hanging with the trace:

Traceback (most recent call last):
  File "C:\Python38\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\Python38\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\ros2_iron\Lib\site-packages\rclpy\executors.py", line 280, in spin
    self.spin_once()
  File "C:\ros2_iron\Lib\site-packages\rclpy\executors.py", line 717, in spin_once
    handler, entity, node = self.wait_for_ready_callbacks(timeout_sec=timeout_sec)
  File "C:\ros2_iron\Lib\site-packages\rclpy\executors.py", line 703, in wait_for_ready_callbacks
    return next(self._cb_iter)
  File "C:\ros2_iron\Lib\site-packages\rclpy\executors.py", line 604, in _wait_for_ready_callbacks
    raise ExternalShutdownException()
rclpy.executors.ExternalShutdownException

I believe this is because once the rclpy signal handler is installed, the KeyboardInterrupt was not getting triggered in the main thread. This makes it so that the executor thread will additionally call shutdown in the case that the signal is handled there first.

mjcarroll commented 1 year ago

CC @Yadunund and @clalancette

clalancette commented 1 year ago

CI:

clalancette commented 1 year ago

@Mergifyio backport iron

mergify[bot] commented 1 year ago

backport iron

✅ Backports have been created

* [#829 Shutdown ros2doctor hello when ctrl-c is received (backport #826)](https://github.com/ros2/ros2cli/pull/829) has been created for branch `iron`