diff --git a/prover_rclpy/setup.py b/prover_rclpy/setup.py index 567230c..201b914 100644 --- a/prover_rclpy/setup.py +++ b/prover_rclpy/setup.py @@ -79,6 +79,7 @@ 'rclpy_1273 = src.rclpy_1273:main', 'rclpy_1287 = src.rclpy_1287:main', 'rclpy_1303 = src.rclpy_1303:main', + 'rclpy_1351 = src.rclpy_1351:main', 'ros2cli_818 = src.ros2cli_818:main', 'ros2cli_862 = src.ros2cli_862:main', 'ros2cli_885 = src.ros2cli_885:main', diff --git a/prover_rclpy/src/rclpy_1351.py b/prover_rclpy/src/rclpy_1351.py new file mode 100644 index 0000000..c8d36ce --- /dev/null +++ b/prover_rclpy/src/rclpy_1351.py @@ -0,0 +1,37 @@ +import threading +import time + +import rclpy +from rclpy.executors import Executor +from rclpy.executors import MultiThreadedExecutor +from rclpy.executors import SingleThreadedExecutor +from rclpy.task import Future + + +def main(args=None): + rclpy.init(args=args) + executor = SingleThreadedExecutor() + + future1 = Future(executor=executor) + future2 = Future(executor=executor) + + # I believe that we need to use ThreadPoolExecutor here... + thread1 = threading.Thread(target=executor.spin_until_future_complete, + args=(future1, 10)) + thread2 = threading.Thread(target=executor.spin_until_future_complete, + args=(future2, 10)) + + thread1.start() + time.sleep(0.5) + thread2.start() + + future1.set_result(True) + future2.set_result(True) + + thread1.join() + thread2.join() + executor.shutdown() + + +if __name__ == '__main__': + main()