Skip to content

Commit

Permalink
fix(DBusProxy): get_dbus_property_async(): unpack GLib.Variant in…
Browse files Browse the repository at this point in the history
… another thread to prevent the mainloop from blocking
  • Loading branch information
linkfrg committed Feb 11, 2025
1 parent ba9fc68 commit cba319f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions ignis/dbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,14 +553,18 @@ def get_dbus_property_async(
"""

def finish(x, res):
def run_callback(value):
if callback:
callback(value, *user_data)

try:
result = self.connection.call_finish(res)
value = result[0]
# python is slow arghhh
# GLib.Variant can contain a lot of data, e.g., pixbuf
# so unpack it in another thread to prevent the mainloop from blocking
Utils.ThreadTask(target=lambda: result[0], callback=run_callback).run()
except GLib.GError as gerror: # type: ignore
value = gerror

if callback:
callback(value, *user_data)
run_callback(gerror)

return self.connection.call(
self.name,
Expand Down

0 comments on commit cba319f

Please sign in to comment.