Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WaitForToppics spends a long time waiting for the thread to join #308

Closed
sloretz opened this issue Apr 7, 2022 · 4 comments
Closed

WaitForToppics spends a long time waiting for the thread to join #308

sloretz opened this issue Apr 7, 2022 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@sloretz
Copy link
Contributor

sloretz commented Apr 7, 2022

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:

while self.__running:
self.__ros_executor.spin_once(1.0)

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.

@sloretz sloretz added enhancement New feature or request good first issue Good for newcomers labels Apr 7, 2022
@Keng12
Copy link
Contributor

Keng12 commented Apr 19, 2022

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)

@sloretz
Copy link
Contributor Author

sloretz commented Apr 19, 2022

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.

@Keng12
Copy link
Contributor

Keng12 commented Apr 23, 2022

I see. Then I will implement your suggestions and create a PR.

@jacobperron
Copy link
Member

Fixed in #314

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants