Skip to content

Commit

Permalink
call Thread.is_alive() to make sure the thread has started.
Browse files Browse the repository at this point in the history
Signed-off-by: Tomoya Fujita <[email protected]>
  • Loading branch information
fujitatomoya committed Aug 21, 2024
1 parent 7818334 commit aeeef82
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions rclpy/test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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:
Expand All @@ -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()
Expand Down

0 comments on commit aeeef82

Please sign in to comment.