diff options
author | Ray Strode <rstrode@redhat.com> | 2020-05-14 15:56:20 -0400 |
---|---|---|
committer | Ray Strode <rstrode@redhat.com> | 2020-05-14 16:31:12 -0400 |
commit | 3c82a664155695bd4243c2a964b3ec22c544f3f6 (patch) | |
tree | b705ba6dc59411004a3d78af42817dd2b4a3dca4 | |
parent | dc72e43b5ab045cd37c2ebdfc26ee50997af87f4 (diff) | |
download | d-feet-3c82a664155695bd4243c2a964b3ec22c544f3f6.tar.gz |
introspection: Load introspection data asynchronously
Some projects, like systemd, have truely gigantic introspection trees.
At the moment that makes d-feet lock up.
To address that problem, this commit changes d-feet to process the
incoming introspection data from an idle handler.
https://gitlab.gnome.org/GNOME/d-feet/-/merge_requests/26
-rw-r--r-- | src/dfeet/introspection.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/dfeet/introspection.py b/src/dfeet/introspection.py index fd41b92..1d6c9f6 100644 --- a/src/dfeet/introspection.py +++ b/src/dfeet/introspection.py @@ -20,6 +20,9 @@ class AddressInfo(): on a given address (eg Gio.BusType.SYSTEM or unix:path=/var/run/dbus/system_bus_socket) """ def __del__(self): + if self.__introspection_idle_id: + GLib.source_remove(self.__introspection_idle_id) + try: self.connection.close() except GLib.GError: @@ -53,6 +56,8 @@ class AddressInfo(): self.__label_address = ui.get_widget('label_address') self.__messagedialog = ui.get_widget('messagedialog') self.__messagedialog.connect("close", self.__messagedialog_close_cb) + self.__object_paths_to_introspect = [] + self.__introspection_idle_id = 0 # connect signals ui.connect_signals(signal_dict) if self.connection_is_bus: @@ -163,7 +168,8 @@ class AddressInfo(): self.__get_stats() # start introspection - self.__dbus_node_introspect("/") + self.__object_paths_to_introspect.append("/") + self.__dbus_node_introspect() def __button_reload_clicked_cb(self, widget): """reload the introspection data""" @@ -240,9 +246,9 @@ class AddressInfo(): # node_iter = self.__treemodel.append(tree_iter, [node.path, node]) if object_path == "/": object_path = "" - object_path_new = object_path + "/" + node.path - self.__dbus_node_introspect(object_path_new) - else: + self.__object_paths_to_introspect.append(object_path + "/" + node.path) + + if not self.__object_paths_to_introspect: # no nodes left. we finished the introspection self.__spinner.stop() self.__spinner.set_visible(False) @@ -251,10 +257,13 @@ class AddressInfo(): self.__label_unique_name.set_text(self.unique_name) self.introspect_box.show_all() + else: + self.__introspection_idle_id = GLib.idle_add(self.__dbus_node_introspect) - def __dbus_node_introspect(self, object_path): + def __dbus_node_introspect(self): """Introspect the given object path. This function will be called recursive""" # start spinner + object_path = self.__object_paths_to_introspect.pop(0) self.__spinner.start() self.__spinner.set_visible(True) # start async dbus call |