From 492d3a463cdda15d8a863ada9ed070c530996dfc Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Fri, 29 Jul 2022 16:35:16 -0700 Subject: [PATCH] setup: Allow starting installation when package manager is busy Allows multiple apps to be queued up for installation. The operation for installing the package will wait for the package manager to become available. Wait for 24 hours before giving up. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/package.py | 8 ++++++++ plinth/setup.py | 4 ---- plinth/templates/setup.html | 11 ++--------- plinth/views.py | 2 -- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/plinth/package.py b/plinth/package.py index a7dbcb734..c03223eb4 100644 --- a/plinth/package.py +++ b/plinth/package.py @@ -9,6 +9,7 @@ import logging import pathlib import subprocess import threading +import time from typing import Optional, Union import apt.cache @@ -403,6 +404,13 @@ def install(package_names, skip_recommends=False, force_configuration=None, return + start_time = time.time() + while is_package_manager_busy(): + if time.time() - start_time >= 24 * 3600: # One day + raise PackageException(_('Timeout waiting for package manager')) + + time.sleep(3) # seconds + logger.info('Running install for app - %s, packages - %s', operation.app_id, package_names) diff --git a/plinth/setup.py b/plinth/setup.py index 718127465..510ea8591 100644 --- a/plinth/setup.py +++ b/plinth/setup.py @@ -176,10 +176,6 @@ def _run_first_setup(): def _run_regular_setup(): """Run setup on all apps also installing required packages.""" - # TODO show notification that upgrades are running - if package.is_package_manager_busy(): - raise Exception('Package manager is busy.') - app_ids = _get_apps_for_regular_setup() run_setup_on_apps(app_ids, allow_install=True) diff --git a/plinth/templates/setup.html b/plinth/templates/setup.html index 6895ddfa6..77501a018 100644 --- a/plinth/templates/setup.html +++ b/plinth/templates/setup.html @@ -34,14 +34,7 @@
{% csrf_token %} - {% if package_manager_is_busy %} - - {% elif has_unavailable_packages %} + {% if has_unavailable_packages %}