Re: GTK+ app development: avahi service browsing and Gtk+ main loop problem
- From: Andrei Macavei <andrei macavei89 gmail com>
- To: Chris Vine <chris cvine freeserve co uk>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: GTK+ app development: avahi service browsing and Gtk+ main loop problem
- Date: Wed, 18 Jun 2014 02:03:44 +0300
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.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]