I would like to elaborate more on my more findings of case b) and c); I hope to be as thorough as possible ::<br><br><br><br>*<br>I have almost confirmed from my side, that is impossible to run two loops in a single thread of execution.<br>
<br>So, for example, once the GUI sets in via<br> Gtk.main()<br><br>that's it.. the thread will now not proceed to any further of code.<br><br><br>Same happens, if the other loop, is run via ::<br>
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)<br> session_bus = dbus.SessionBus()<br> name = dbus.service.BusName("org.example.Sample", session_bus)<br>
object = ExampleObject(session_bus, '/ExampleObject')<br> mainloop = GObject.MainLoop()<br><br>So, if two different loops need to be run, we need to have threads. Period.<br>
<br>PLEASE LET ME KNOW IF MY ASSERTIONS ARE CORRECT :)<br><br><br><br>*<br>Now, when I tried running the two loops in two different threads, I enountered strange errors.<br>I dare say that they seem to be due to inappropriate specification of the event sources for the two loops (which in turn is wholly due to my limited knowledge of dbus-loops).<br>
<br>Which brings me to the following related questions ::<br><br> 1)<br> As per <a href="http://www.pygtk.org/pygtk2reference/class-gobjectmainloop.html">http://www.pygtk.org/pygtk2reference/class-gobjectmainloop.html</a>, it seems that we must be able to add event sources to <br>
gobject.mainloop; however, I do not see any way to that. <br><br> HOW CAN EVENT SOURCES BE ADDED?<br><br><br> 2)<br> Once the event sources are added, each instance of gobject.mainloop (in its particular thread), will cater to only those sources.<br>
<br> PLEASE LET ME KNOW IF MY ASSERTION IS CORRECT.<br><br><br> 3)<br> How is dbus."mainloop.glib.DBusGMainLoop(set_as_default=True)" related to gobject.mainloop?<br><br><br> 4)<br>
How is dbus."mainloop.glib.DBusGMainLoop(set_as_default=False)" related to gobject.mainloop?<br><br> <br> 5)<br> Is it necessary at all to specify "mainloop.glib.DBusGMainLoop(set_as_default=True)" or <br>
"mainloop.glib.DBusGMainLoop(set_as_default=False)" when using gobject.mainloop?<br><br><br>I know some of the answers are obvious (like points 2 and 5), but I notice whatever I have searched on the net, people are just happy to get things working.<br>
This is ok if there is just a single thread with a single gobject.mainloop, but things get monstrous when two loops (one a "Gtk.main()", and other "gobject.mainloop") come in; as now things won't work unless there is a clear understanding of what each line of bootstrapping-code does.<br>
<br><br>I will be grateful to receive any in-sights in this.<br><br><br><br><br> <br> <br> <br>
<br><div class="gmail_quote">On Mon, Dec 24, 2012 at 1:56 PM, Ajay Garg <span dir="ltr"><<a href="mailto:ajaygargnsit@gmail.com" target="_blank">ajaygargnsit@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all.<br><br>This is another question that arises as part of my efforts to run a GUI application, as well as a dbus-service within the same process.<br>(The other question being at <a href="http://mail.python.org/pipermail/python-dev/2012-December/123287.html" target="_blank">http://mail.python.org/pipermail/python-dev/2012-December/123287.html</a>)<br>
<br>For a recap of the brief history, I have a parent process, that is spawning a child process via "subprocess".<br>Currently, the child-process is a GUI process; however, I intend to "behave" it as a dbus-service as well.<br>
<br>Thus,<br><br>a)<br>I subclassed the child-process "main" class with "dbus.service.Object"; however, I then got the error <br>"<code><span>metaclass conflict</span><span>:</span><span> the metaclass of a derived </span><span>class</span><span> must be a </span><span>(</span><span>non</span><span>-</span><span>strict</span><span>)</span><span> subclass of the metaclasses of all its bases</span></code>"<br>
<br><br>b)<br>I then used composition, wherein another class, "RemoteListener" deriving from "dbus.service.Object" was made an attribute of the "main" class. That worked.<br>However, when I do<br>
<br> dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)<br> GObject.mainloop.run()<br><br>in the "RemoteListener"'s __init__ method, the GUI of the "main" class fails to load (apparently, because the "mainloop.run()" causes the singular, main-thread to go into busy-wait).<br>
<br><br>c)<br>I tried option b), but now instantiating "RemoteListener" in a separate thread; however, no improvement :(<br><br><br><br><br>Is there a way to run GUI and a dbus-service together? Or is a dbus-service pure "backend" process? :P<br>
<br>I will be grateful for any pointers; if you need me to test anything else, please let me know, I will be more than willing :)<br clear="all"><br><br><br><br>Regards,<br>Ajay<br>
</blockquote></div><br><br clear="all"><br>Regards,<br>Ajay<br>