-
Notifications
You must be signed in to change notification settings - Fork 233
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
Race condition in MultiThreadedExecutor
#1393
Comments
In your test, is it possible to call _spin_once_impl() simultaneously from different threads for the same executor ? |
I thought not; that's why I was skeptical. But upon further inspection, there is a case!
They necessarily run in parallel. Is that intended usage of a |
For the same executor, spin_until_future_complete() should not be run in parallel. So I think this isn't the correct way to use it. |
Hmm, is there some documentation on what is thread-safe and what isn't? I must've missed it if it exists. I'm honestly a bit lost on properly doing this kind of thing if not that way. Is there some other way in which one can wait for a |
Bug report
Required Info:
rolling
viaros-tooling/[email protected]
GitHub actionSteps to reproduce the issue
Documented here: felixdivo/ros2-easy-test#45. It is not 100% reproducible, yet it occurs frequently in my repo.
Expected behavior
No exception is raised.
Actual behavior
Additional information
Previously, I had similar issues caused by race conditions reported in #1129. This again appears to be caused by multiple threads simultaneously acting on the executor. Is there some unintended usage by me?
Possible solution
If not, I suggest going with the it is "Easier to ask for forgiveness than permission" and just wrap the
self._futures.remove(future)
in a try-except block catching andValueError
s. I can also do that if you confirm it is a reasonable path forward.The text was updated successfully, but these errors were encountered: