[Merge] ~nteodosio/update-manager:purgeidleloop2 into update-manager:main
Marco Trevisan (TreviƱo)
mp+475111 at code.launchpad.net
Wed Oct 16 12:08:07 UTC 2024
Diff comments:
> diff --git a/UpdateManager/UpdateManager.py b/UpdateManager/UpdateManager.py
> index 7f75914..903d4ee 100644
> --- a/UpdateManager/UpdateManager.py
> +++ b/UpdateManager/UpdateManager.py
> @@ -277,22 +274,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})
Well, it's still safer IMHO to ensure that something that has been started in a thread gets completed in the same, since there may be other things that break otherwise.
For example in this cases it changes some class data, and it may create races if other things are accessing to them.
So in general if you call a thread, always ensure that the callback happens in the same that created it.
> 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