Re: GTK+ app development: avahi service browsing and Gtk+ main loop problem
On Tue, 17 Jun 2014 10:51:21 +0300 Andrei Macavei andrei.macave...@gmail.com wrote: I am resending the code examples in plain text as the first message contained some html part which made the code un-copy-paste-able. The problem description can be summarized as : when using gtk's main loop ( Gtk.main() ) how to deal with gobject.MainLoop.().run() which is used by avahi client. I do not know python particularly well but you probably first need to explain why you are running two main loops. Can't your program just use one, so that you can use the default main loop for both? Chris ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GTK+ app development: avahi service browsing and Gtk+ main loop problem
On 17.06.2014 12:43, Chris Vine wrote: I do not know python particularly well but you probably first need to explain why you are running two main loops. Can't your program just use one, so that you can use the default main loop for both? Chris Hi, I haven't shown the full code of the ServiceDiscover class, I will post it here again after my message. In the ServiceDiscover class , in the method discover() , a dbus.Interface object is connected to the signal ItemNew : . self.sbrowser.connect_to_signal(ItemNew, self.handler) . Afterwards it must call the main loop or else it cannot use the above signal I suppose. This has to be done inside the ServiceDiscover class. The code for both the service publishing and service browsing using avahi is taken from avahi website: http://avahi.org/wiki/PythonBrowseExample http://avahi.org/wiki/PythonPublishExample The problem is that I have to use a main loop inside the ServiceDiscover class, and another one for the gtk+ main window class. I am copy-pasting the full traceback of the error: Traceback (most recent call last): File MainWindow.py, line 32, in module window = MainWindow() File MainWindow.py, line 29, in __init__ service_discover.discover() File /home/kheops/gsoc/geysigning/network/AvahiDiscover.py, line 28, in discover self.sbrowser.connect_to_signal(ItemNew, self.handler) File /usr/lib/python2.7/dist-packages/dbus/proxies.py, line 544, in connect_to_signal dbus_interface, **keywords) File /usr/lib/python2.7/dist-packages/dbus/proxies.py, line 369, in connect_to_signal **keywords) File /usr/lib/python2.7/dist-packages/dbus/bus.py, line 148, in add_signal_receiver path, **keywords) File /usr/lib/python2.7/dist-packages/dbus/connection.py, line 400, in add_signal_receiver self._require_main_loop() RuntimeError: To make asynchronous calls, receive signals or export objects, D-Bus connections must be attached to a main loop by passing mainloop=... to the constructor or calling dbus.set_default_main_loop(...) --- Here is a link on dpaste for the full avahi discover class: http://dpaste.com/3DDGFER ~Andrei M. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GTK+ app development: avahi service browsing and Gtk+ main loop problem
On Wed, 18 Jun 2014 02:03:44 +0300 Andrei Macavei andrei.macave...@gmail.com wrote: On 17.06.2014 12:43, Chris Vine wrote: I do not know python particularly well but you probably first need to explain why you are running two main loops. Can't your program just use one, so that you can use the default main loop for both? Chris Hi, I haven't shown the full code of the ServiceDiscover class, I will post it here again after my message. In the ServiceDiscover class , in the method discover() , a dbus.Interface object is connected to the signal ItemNew : . self.sbrowser.connect_to_signal(ItemNew, self.handler) . Afterwards it must call the main loop or else it cannot use the above signal I suppose. This has to be done inside the ServiceDiscover class. The code for both the service publishing and service browsing using avahi is taken from avahi website: http://avahi.org/wiki/PythonBrowseExample http://avahi.org/wiki/PythonPublishExample The problem is that I have to use a main loop inside the ServiceDiscover class, and another one for the gtk+ main window class. I cannot really help you, as I would need a greater knowledge of python's dbus interface and avahi's interfaces than I possess in order to do so. When using gio's C interface for dbus, I have never had to futz around with different main loops - the default program main loop (the one which gtk+ uses) is automatically used for gio's asynchronous continuations unless you go out of your way to set up something different using g_main_context_push_thread_default(). I am also highly suspicious of the use of two main loops, which amongst other things requires a thread for each main loop, but maybe this is an avahi thing. It begs the question of how the two main loops communicate with each other, and why. In addition it looks as if your python library wraps dbus-glib rather than gio's dbus implementation and I do not know what options that gives you for main loops, as I don't use it. Chris ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list