Re: "connections-read" signal not emitted reliably?



Hey,

On Wed, Jun 25, 2014 at 9:53 AM, Aleksander Morgado
<aleksander aleksander es> wrote:
Using NM 0.9.8.8 and seeing an issue with the "connections-read"
callback in NMClient.RemoteSettings; basically, the callback isn't
being fired. This only seems to happen if NM is started and right away
(after NM is in the bus) a program creates a NMClient.RemoteSettings
and connects to the signal. Any idea?

Re-looking at the code, I think I found the culprit... The code looks like this:

    # Setup main event loop
    main_loop = GLib.MainLoop()

    # Create NM singletones
    settings = NMClient.RemoteSettings.new(None)
    client = NMClient.Client.new()

    # Create MM singletones
    systembus = Gio.bus_get_sync (Gio.BusType.SYSTEM, None)
    mm_manager = ModemManager.Manager.new_sync (systembus,

Gio.DBusObjectManagerClientFlags.DO_NOT_AUTO_START,
                                                None)

    # Don't try to read connections if NM is not running
    if settings.get_property("service-running") == False:
        sys.exit("error: NM service is not running")

    # Look for existing connection settings first
    # Connections are read asynchronously, so we need to wait for the
    # settings object to tell us that it's read all connections
    trace("NM service is running... reading connection list")
    settings.connect("connections-read", connections_read)

    main_loop.run()


Even if I don't start my main loop until after I have connected to the
signal, the _sync() operations that are run in between will have an
inner mainloop themselves, so it's likely that the 'connections-read'
signal for the settings object I created earlier arrives during those
loops; and then when I connect to the 'connections-read' signal it is
already too late to receive it... So I guess I can just create the
settings object right before connecting to the signal, and let my own
main loop deliver it.

-- 
Aleksander
https://aleksander.es


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]