Skip to content

Commit

Permalink
MultiThreadedExecutor.shutdown does not shut down underlying threadpool
Browse files Browse the repository at this point in the history
  ros2/rclpy#893

Signed-off-by: Tomoya Fujita <[email protected]>
  • Loading branch information
fujitatomoya committed Jun 28, 2024
1 parent 3440016 commit 09a7975
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions prover_rclpy/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
'rclpy_857 = src.rclpy_857:main',
'rclpy_879 = src.rclpy_879:main',
'rclpy_881 = src.rclpy_881:main',
'rclpy_893 = src.rclpy_893:main',
'rclpy_911 = src.rclpy_911:main',
'rclpy_912 = src.rclpy_912:main',
'rclpy_944 = src.rclpy_944:main',
Expand Down
34 changes: 34 additions & 0 deletions prover_rclpy/src/rclpy_893.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import threading

import rclpy
from rclpy.executors import MultiThreadedExecutor
from rclpy.node import Node

class TestNode(Node):
def __init__(self, n=10):
super().__init__('test_node')
# Create a timer to give the executor something to do
self.create_timer(0., callback=lambda: None)


def main(args=None):
rclpy.init()
executor = MultiThreadedExecutor()
node = TestNode()


# Spin once to give the executor some work to do (creating threads)
rclpy.spin_once(node, executor=executor)

print("Shutting down")
rclpy.shutdown()
node.destroy_node()
# This will shutdown the ThreadpoolExecutor
#executor._executor.shutdown()
executor.shutdown()

print(f"Leftover Threads: {threading.enumerate()}")


if __name__ == '__main__':
main()

0 comments on commit 09a7975

Please sign in to comment.