WaitForToppics spends a long time waiting for the thread to join
Closed this issue · 4 comments
While debugging #304 I noticed WaitForTopics
spends a lot of time joining the thread it creates (up to 1 second).
It looks like the thread spins for a whole second before checking if it should shutdown:
launch_ros/launch_testing_ros/launch_testing_ros/wait_for_topics.py
Lines 73 to 74 in a114e1f
I suspect this could be fixed by deleting _spin_function
and using self.__ros_executor.spin
as the thread target.
Then the thread could be joined must faster by shutting down the rclpy.Context
before trying to join it.
Couldn't the same be achieved by changing the timeout parameter from 1.0 to 0? I. e.:
self.__ros_executor.spin_once(0.0)
Couldn't the same be achieved by changing the timeout parameter from 1.0 to 0?
0
means the executor won't wait for work. Without any other blocking it would use up to a full CPU core.
I see. Then I will implement your suggestions and create a PR.
Fixed in #314