Is it possible for a single dbus-python exported object to dispatch multiple methods at once? I have one object that exports a few (slow) methods, and in another program I quickly call them (asynchronously). The slow object is printing at the beginning and end of each method call, so it's clear that the methods aren't being run simultaneously. Instead, each waits for the one before it to finish. Is there some way to get the mainloop to dispatch methods simultaneously?
<br><br>Also, to make sure there wasn't a bug in the async calls, I tried doing all three methods at once in different instances of python, and I get the same problem. "Screenshot" follows:<br><br>tsuraan@localhost
~/test/python/dbus/moreblocking $ cat Slow.py <br>import gobject<br>import dbus<br>import dbus.service<br>import dbus.glib<br>import time<br><br>class Slow(dbus.service.Object):<br> def __init__(self):<br> bus = dbus.SystemBus
()<br> bus_name = dbus.service.BusName("com.example.Slow", bus)<br><br> super(Slow, self).__init__(bus_name, "/Object")<br><br> @dbus.service.method("com.example.Slow")<br> def function1(self):
<br> print 'starting function1'<br> time.sleep(5)<br> print 'done with function1'<br> return 1<br><br> @dbus.service.method("com.example.Slow")<br> def function2(self):<br> print 'starting function2'
<br> time.sleep(5)<br> print 'done with function2'<br> return 2<br><br> @dbus.service.method("com.example.Slow")<br> def function3(self):<br> print 'starting function3'<br> time.sleep
(5)<br> print 'done with function3'<br> return 3<br><br><br>if __name__ == "__main__":<br> gobject.threads_init()<br> dbus.glib.init_threads()<br><br> s = Slow()<br> gobject.MainLoop().run()<br>
<br>tsuraan@localhost ~/test/python/dbus/moreblocking $ cat test.py <br>import gobject<br>import dbus<br>import dbus.glib<br>import time<br><br>def noop(*args):<br> pass<br><br>bus = dbus.SystemBus()<br>obj = bus.get_object
("com.example.Slow", "/Object")<br>obj.function1(reply_handler=noop, error_handler=noop)<br>obj.function2(reply_handler=noop, error_handler=noop)<br>obj.function3(reply_handler=noop, error_handler=noop)
<br><br>gobject.MainLoop().run()<br><br>tsuraan@localhost ~/test/python/dbus/moreblocking $ python Slow.py & sleep 1 && python test.py <br>[1] 18460<br>starting function1<br>done with function1<br>starting function2
<br>done with function2<br>starting function3<br>done with function3<br><br>