[Merge] ~nteodosio/update-manager:purgeidleloop2 into update-manager:main
Marco Trevisan (TreviƱo)
mp+475111 at code.launchpad.net
Tue Oct 15 14:25:02 UTC 2024
Diff comments:
> diff --git a/UpdateManager/UpdateManager.py b/UpdateManager/UpdateManager.py
> index 7f75914..c649336 100644
> --- a/UpdateManager/UpdateManager.py
> +++ b/UpdateManager/UpdateManager.py
> @@ -211,17 +211,11 @@ class UpdateManager(Gtk.Window):
> cmd += ["--toplevel", "%s" % self.get_window().get_xid()]
>
> self._look_busy()
> - try:
> - p = subprocess.Popen(cmd)
> - except OSError:
> - pass
> - else:
> - while p.poll() is None:
> - while Gtk.events_pending():
> - Gtk.main_iteration()
> - time.sleep(0.05)
> - finally:
> - self.start_available()
> + p = Gio.Subprocess.new(cmd, Gio.SubprocessFlags.NONE)
> + p.wait_check_async(None, self.on_show_settings_complete, None)
> +
> + def on_show_settings_complete(self, p, res, arg):
Maybe you can avoid this class function (using lambda or subfunction).
Also is there any chance you can pass a Gio.Cancellable (to be cancelled when required?)
> + self.start_available()
>
> def start_update(self):
> if self.options.no_update:
> @@ -277,22 +271,23 @@ class UpdateManager(Gtk.Window):
> if fnmatch.fnmatch(pkg.name, "oem-*-meta") and pkg.installed:
> self.oem_metapackages.add(pkg)
>
> - def _fetch_ua_updates(self):
> + def _fetch_ua_updates(self, cb=None):
> try:
> self.ua_updates = ua.updates().updates
> except Exception as e:
> print("Error running updates end-point: ", e)
> self.ua_updates = []
> + if cb:
> + cb()
>
> def _get_ua_security_status(self):
> self.ua_security_packages = []
> self.ua_updates = []
> - t = threading.Thread(target=self._fetch_ua_updates, daemon=True)
> + t = threading.Thread(target=self._fetch_ua_updates, daemon=True,
> + kwargs={'cb': self.sift_pro_packages})
Shouldn't this callback be called on GLib idle?
> t.start()
> - while t.is_alive():
> - while Gtk.events_pending():
> - Gtk.main_iteration()
> - time.sleep(0.05)
> +
> + def sift_pro_packages(self):
> for package in self.ua_updates:
> if (
> package.provided_by == 'standard-security'
--
https://code.launchpad.net/~nteodosio/update-manager/+git/update-manager/+merge/475111
Your team Ubuntu Core Development Team is subscribed to branch update-manager:main.
More information about the Ubuntu-reviews
mailing list