Closed khurshid-alam closed 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
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
I am using Kupfer v 317. Empathy has stopped working for me. It somehow can not initiate dbus connection:
Can you fix it?