hugosenari / Kupfer-Plugins

My kupfer plugins install with Kupfer
https://github.com/kupferlauncher/kupfer/
11 stars 2 forks source link

Empathy again doesn't work for New Kupfer #7

Closed khurshid-alam closed 7 years ago

khurshid-alam commented 7 years ago

I am using Kupfer v 317. Empathy has stopped working for me. It somehow can not initiate dbus connection:

Error [kupfer.plugin.empathy]: DBusException org.freedesktop.DBus.Error.UnknownMethod: Method "Get" with signature "ss" on interface "(null)" doesn't exist

Error [kupfer.plugin.empathy]: DBusException org.freedesktop.DBus.Error.UnknownMethod: Method "Get" with signature "ss" on interface "(null)" doesn't exist

Error [kupfer.plugin.empathy]: DBusException org.freedesktop.DBus.Error.UnknownMethod: Method "Get" with signature "ss" on interface "(null)" doesn't exist

Error [kupfer.plugin.empathy]: DBusException org.freedesktop.DBus.Error.UnknownMethod: Method "Get" with signature "ss" on interface "(null)" doesn't exist

Error [kupfer.plugin.empathy]: DBusException org.freedesktop.DBus.Error.UnknownMethod: Method "Get" with signature "ss" on interface "(null)" doesn't exist

Error [kupfer.plugin.empathy]: DBusException org.freedesktop.DBus.Error.UnknownMethod: Method "Get" with signature "ss" on interface "(null)" doesn't exist

Can you fix it?

hugosenari commented 7 years ago

In dbus at py3 when you set multiple handle for same object method, last handler is callback both method calls.

Solutions: 1 - Change to 'block' version, and wait for each response 2 - Fill a bug at Python DBus

hugosenari commented 7 years ago

Trying to understand what happen here I discovered that isn't a Python DBus bug :) It is know as Late Binding Clousure, basically when define a method values that came from scope above isn't resolved at method definition time, but at method execution time.

Above code can be used as example:

import dbus
from dbus.mainloop.glib import DBusGMainLoop

sbus = dbus.SessionBus(mainloop=DBusGMainLoop(set_as_default=True))

for n in range(5):
    proxy_object = sbus.get_object('org.freedesktop.DBus', '/')

    def reply(i):
        def result(result):
            print('N (Late Binding Clousure):', n, ' | Expected:', i)
        return result

    proxy_object.GetId(
        reply_handler=reply(n),
        error_handler=lambda *args, **kwds: (args, kwds)
    )

import gi.repository.GLib
mainloop = gi.repository.GLib.MainLoop()
mainloop.run()

Output:

N (Late Binding Clousure): 4  | Expected: 0
N (Late Binding Clousure): 4  | Expected: 1
N (Late Binding Clousure): 4  | Expected: 2
N (Late Binding Clousure): 4  | Expected: 3
N (Late Binding Clousure): 4  | Expected: 4