Following this example I want to stop the service when I get all elements and return them in a list.
To stop the infinite loop is to call gobject.MainLoop().quit()
, but do not know when or where to call.
Thanks
Following this example I want to stop the service when I get all elements and return them in a list.
To stop the infinite loop is to call gobject.MainLoop().quit()
, but do not know when or where to call.
Thanks
You'll want to stop the service browsing when the last service for now has arrived. This will give you a snapshot of the current available services.
There is a flag in the C layer allowing you to inspect whether more services are comming shortly. It's called AVAHI_BROWSER_ALL_FOR_NOW
. I'm not familiar with the python bindings, but perhaps this flag can be inspected somehow in the stype
or flags
arguments of the callback?
When you see this flag is set - call gobject.MainLoop().quit()
You'll want to listen to the AllForNow signal as well. Consider CacheExhausted and Failure as well. The interface for org.freedesktop.Avahi.ServiceBrowser is declared here.
Running the following on my machine returns in about a second and prints:
Hope it helps!