From 3d203961252d4c3eb1a191e807058ac3a1a5214e Mon Sep 17 00:00:00 2001 From: Tomoya Fujita Date: Tue, 25 Jun 2024 13:25:35 -0700 Subject: [PATCH] call Thread.is_alive() to make sure the thread has started. Signed-off-by: Tomoya Fujita --- rclpy/test/test_client.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rclpy/test/test_client.py b/rclpy/test/test_client.py index e9ea9e312..207dc0aac 100644 --- a/rclpy/test/test_client.py +++ b/rclpy/test/test_client.py @@ -213,6 +213,8 @@ def _service(request, response): executor_thread = threading.Thread( target=TestClient._spin_rclpy_node, args=(self.node, executor)) executor_thread.start() + # make sure thread has started to avoid exception via join() + self.assertTrue(executor_thread.is_alive()) result = cli.call(GetParameters.Request(), 0.5) self.assertTrue(result is not None) executor.shutdown() @@ -234,6 +236,8 @@ def _service(request, response): executor_thread = threading.Thread( target=TestClient._spin_rclpy_node, args=(self.node, executor)) executor_thread.start() + # make sure thread has started to avoid exception via join() + self.assertTrue(executor_thread.is_alive()) with self.assertRaises(TimeoutError): cli.call(GetParameters.Request(), 0.5) finally: @@ -253,6 +257,8 @@ def _service(request, response): executor_thread = threading.Thread( target=TestClient._spin_rclpy_node, args=(self.node, executor)) executor_thread.start() + # make sure thread has started to avoid exception via join() + self.assertTrue(executor_thread.is_alive()) result = cli.call(GetParameters.Request(), 0.5) self.assertTrue(result is not None) executor.shutdown()