-
Notifications
You must be signed in to change notification settings - Fork 51
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
Introspection fails when called multiple times in threads #73
Comments
Hi, thanks for the report! In ruby-dbus, thread safety is more of an accident than a goal. That said, I think I have found a workaround for your use case: - sys_bus = DBus.system_bus
+ sys_bus = DBus::ASystemBus.new which makes each thread use its own connection. With that, your example works for me. Does it help for you? I should document that. |
Thank you @mvidner that works very well ! I even tried the sample script with 200 threads running in parallel and did not see any issues. Will do more tests with Puma. Documenting this would be great as other people may hit this too. I don't know if we should close this issue or wait for documentation update, or if you have something else in mind. |
Good to hear that! I'll document it and then close this myself. |
The previous attempt at thread safety failed (#7, #73) but now I see a limited use case: A worker thread only uses the shared bus connection to send signals about its progress and completion. No method calls are accepted there. That is, we only race for the bus connection in MessageQueue#push, not in the #pop reading part.
The previous attempt at thread safety failed (#7, #73) but now I see a limited use case: A worker thread only uses the shared bus connection to send signals about its progress and completion. No method calls are accepted there. That is, we only race for the bus connection in MessageQueue#push, not in the #pop reading part.
I am trying to build a Rails application that regularly checks network status, Systemd service status etc. showing them on the UI. I need to use Puma which works with threads. When the application makes calls to DBus we start getting DBus::InvalidPacketException over and over during introspection. I am not sure if it is because of using threads, or if threads just makes it easier to reproduce (ex. calling DBus too fast).
I see it happen on OpenSUSE 42.3 and Ubuntu 16.04. Happens with Ruby 2.4.3 and 2.3.6, did not try other Ruby versions. This is reproducable with 2 threads too. Systemd is just an example, issue happens when calling NetworkManager too.
and the errors I get changes time to time but they all look like introspection data is not correct so it is not parsed properly
You can find the sample script to reproduce the issue (no Rails, just Ruby) and some info here too https://github.com/zaburt/ruby-dbus-test . I can try out any test code or suggestions.
The text was updated successfully, but these errors were encountered: