[Merge] ~nteodosio/update-manager:calculation-hang-thread-upper-function into update-manager:main
Marco Trevisan (TreviƱo)
mp+475707 at code.launchpad.net
Thu Oct 24 09:48:41 UTC 2024
Diff comments:
> diff --git a/UpdateManager/UpdateManager.py b/UpdateManager/UpdateManager.py
> index 7f75914..7a54854 100644
> --- a/UpdateManager/UpdateManager.py
> +++ b/UpdateManager/UpdateManager.py
> @@ -242,19 +248,110 @@ class UpdateManager(Gtk.Window):
> self._start_pane(install_backend)
>
> def start_available(self, cancelled_update=False, error_occurred=False):
> + def refresh_cache(task, source_obj, data, cancellable):
> + try:
> + if self.cache is None:
> + self.cache = MyCache(None)
> + else:
> + self.cache.open(None)
> + self.cache._initDepCache()
> + except AssertionError as e:
> + task.return_value((ExitType.BROKEN_INDEX, e))
> + except SystemError as e:
> + task.return_value((ExitType.CANT_INIT_INFO, e))
Wouldn't be better to use `task.return_new_error_literal` instead of defining the new enum?
Then you can just rely on `task.propagate_value()` exception to handle such cases.
> +
So my feeling is that here you should just task.return_value((ExitType.NORMAL, None)) because it's where the task busy thread is done and starting from now you should just operate in the main thread, isn't it?
If so, such operations should be done after task.propagate_value() has been called and returned with no failure.
> + self._check_oem_metapackages()
> +
> + self._get_ua_security_status()
> +
> + for pkgname in self.oem_metapackages:
> + try:
> + if not self.cache[pkgname].is_installed:
> + self.cache[pkgname].mark_install()
> + except SystemError:
> + pass
> +
> + self.update_list = UpdateList(self)
> + try:
> + self.update_list.update(
> + self.cache,
> + duplicate_packages=self.duplicate_packages,
> + ua_security_packages=self.ua_security_packages,
> + )
> + except SystemError as e:
> + task.return_value((ExitType.INCALCULABLE, e))
> +
> + if self.update_list.distUpgradeWouldDelete > 0:
> + task.return_value((ExitType.PARTIAL_UPGRADE, None))
> + task.return_value((ExitType.NORMAL, None))
> +
> self._look_busy()
> - self.refresh_cache()
>
> - if self.cache is None:
> + t = Gio.Task.new(self, None, self.cache_refreshed,
> + (cancelled_update, error_occurred))
> + t.run_in_thread(refresh_cache)
> +
> + def cache_refreshed(self, source, task, data):
> + cancelled_update, error_occurred = data
> + try:
> + task_returned, task_result = task.propagate_value()
> + exitcode, exception = task_result
> + # FIXME how to get child thread exception and display it to the user?
> + except:
> + header = _("Failed to refresh cache")
> + desc = _(
> + "The refresh_cache thread crashed.\n\n"
I'd use something more user friendly: "Refreshing the cache failed"
> + "Please report this bug against the 'update-manager' "
> + "package and include the thread traceback in the terminal.\n"
> + )
> + self.start_error(False, header, desc)
> return
>
> - pane = self._make_available_pane(
> - self.cache.install_count + self.cache.del_count,
> - os.path.exists(REBOOT_REQUIRED_FILE),
> - cancelled_update,
> - error_occurred,
> - )
> - self._start_pane(pane)
> + if exitcode is ExitType.BROKEN_INDEX:
> + # if the cache could not be opened for some reason,
> + # let the release upgrader handle it, it deals
> + # a lot better with this
> + self._start_pane(PartialUpgradeDialog(self))
> + # we assert a clean cache
> + header = _("Software index is broken")
> + desc = _(
> + "It is impossible to install or remove any software. "
> + 'Please use the package manager "Synaptic" or run '
> + '"sudo apt-get install -f" in a terminal to fix '
> + "this issue at first."
> + )
> + self.start_error(False, header, desc)
> + elif exitcode is ExitType.CANT_INIT_INFO:
> + header = _("Could not initialize the package information")
> + desc = _(
> + "An unresolvable problem occurred while "
> + "initializing the package information.\n\n"
> + "Please report this bug against the 'update-manager' "
> + "package and include the following error message:\n"
> + ) + str(exception)
> + self.start_error(True, header, desc)
> + elif exitcode is ExitType.INCALCULABLE:
> + header = _("Could not calculate the upgrade")
> + desc = _(
> + "An unresolvable problem occurred while "
> + "calculating the upgrade.\n\n"
> + "Please report this bug against the 'update-manager' "
> + "package and include the following error message:\n"
> + ) + str(exception)
> + self.start_error(True, header, desc)
> + elif exitcode is ExitType.PARTIAL_UPGRADE:
> + self._start_pane(PartialUpgradeDialog(self))
> + else:
> + if self.cache is None:
> + return
> +
> + pane = self._make_available_pane(
> + self.cache.install_count + self.cache.del_count,
> + os.path.exists(REBOOT_REQUIRED_FILE),
> + cancelled_update,
> + error_occurred,
> + )
> + self._start_pane(pane)
>
> def _check_oem_metapackages(self):
> di = distro_info.UbuntuDistroInfo()
--
https://code.launchpad.net/~nteodosio/update-manager/+git/update-manager/+merge/475707
Your team Ubuntu Core Development Team is subscribed to branch update-manager:main.
More information about the Ubuntu-reviews
mailing list