-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MultiThreadedExecutor.shutdown does not shut down underlying threadpool
ros2/rclpy#893 Signed-off-by: Tomoya Fujita <[email protected]>
- Loading branch information
1 parent
3440016
commit 09a7975
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |