From 02c320f553187a82484ff618bfd547ceccbe9b11 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Sat, 20 Jul 2019 04:44:36 +0200 Subject: [PATCH 1/5] [mod] add debug log telling we are trying to aquired the log --- moulinette/core.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/moulinette/core.py b/moulinette/core.py index ecd78494..f10523c5 100644 --- a/moulinette/core.py +++ b/moulinette/core.py @@ -461,6 +461,8 @@ class MoulinetteLock(object): """ start_time = time.time() + logger.debug('acquiring lock...') + while True: lock_pids = self._lock_PIDs() From 44878d71480f0b20379383e6e51987c00e2cc136 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Sat, 20 Jul 2019 04:45:01 +0200 Subject: [PATCH 2/5] [ux] add a warning mecanism to inform the user about the current lock --- locales/en.json | 4 +++- moulinette/core.py | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/locales/en.json b/locales/en.json index 32c9eec8..634a85c1 100644 --- a/locales/en.json +++ b/locales/en.json @@ -51,5 +51,7 @@ "download_timeout": "{url:s} took too long to answer, gave up.", "download_unknown_error": "Error when downloading data from {url:s}: {error:s}", "download_bad_status_code": "{url:s} returned status code {code:s}", - "command_unknown": "Command '{command:s}' unknown?" + "command_unknown": "Command '{command:s}' unknown ?", + "warn_the_user_about_waiting_lock": "another YunoHost command is running right now, we are waiting for it to finish before running this one", + "warn_the_user_about_waiting_lock_again": "still waiting..." } diff --git a/moulinette/core.py b/moulinette/core.py index f10523c5..4de9d0fc 100644 --- a/moulinette/core.py +++ b/moulinette/core.py @@ -461,6 +461,13 @@ class MoulinetteLock(object): """ start_time = time.time() + # for UX reason, we are going to warn the user that we are waiting for + # another yunohost command to end, otherwise the user is very confused + # and don't understand that and think yunohost is broken + # we are going to warn the user after 15 seconds of waiting time then + # after 15*4 seconds, then 15*4*4 seconds... + warning_treshold = 15 + logger.debug('acquiring lock...') while True: @@ -485,6 +492,15 @@ class MoulinetteLock(object): if self.timeout is not None and (time.time() - start_time) > self.timeout: raise MoulinetteError('instance_already_running') + + # warn the user if it's been too much time since they are waiting + if (time.time() - start_time) > warning_treshold: + if warning_treshold == 15: + logger.warning(moulinette.m18n.g('warn_the_user_about_waiting_lock')) + else: + logger.warning(moulinette.m18n.g('warn_the_user_about_waiting_lock_again')) + warning_treshold *= 4 + # Wait before checking again time.sleep(self.interval) From 122f6a3670a06076ec903b2196dfc856f0a1cdef Mon Sep 17 00:00:00 2001 From: Bram Date: Sat, 20 Jul 2019 14:42:52 +0200 Subject: [PATCH 3/5] [mod] capitalize Co-Authored-By: decentral1se --- locales/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locales/en.json b/locales/en.json index 634a85c1..642504fc 100644 --- a/locales/en.json +++ b/locales/en.json @@ -53,5 +53,5 @@ "download_bad_status_code": "{url:s} returned status code {code:s}", "command_unknown": "Command '{command:s}' unknown ?", "warn_the_user_about_waiting_lock": "another YunoHost command is running right now, we are waiting for it to finish before running this one", - "warn_the_user_about_waiting_lock_again": "still waiting..." + "warn_the_user_about_waiting_lock_again": "Still waiting..." } From 96a0774736bd7f3aa40a1fafe68f5fe1feb31739 Mon Sep 17 00:00:00 2001 From: Bram Date: Mon, 22 Jul 2019 01:45:54 +0200 Subject: [PATCH 4/5] [mod] capitalise message Co-Authored-By: decentral1se --- locales/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locales/en.json b/locales/en.json index 642504fc..f57bce9d 100644 --- a/locales/en.json +++ b/locales/en.json @@ -52,6 +52,6 @@ "download_unknown_error": "Error when downloading data from {url:s}: {error:s}", "download_bad_status_code": "{url:s} returned status code {code:s}", "command_unknown": "Command '{command:s}' unknown ?", - "warn_the_user_about_waiting_lock": "another YunoHost command is running right now, we are waiting for it to finish before running this one", + "warn_the_user_about_waiting_lock": "Another YunoHost command is running right now, we are waiting for it to finish before running this one", "warn_the_user_about_waiting_lock_again": "Still waiting..." } From ca49ffefc13f8f6484e4a86a90782860d18c3717 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Thu, 25 Jul 2019 04:15:52 +0200 Subject: [PATCH 5/5] [ux] also inform the user once we've stopped waiting for the lock --- locales/en.json | 3 ++- moulinette/core.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/locales/en.json b/locales/en.json index f57bce9d..4ca0048e 100644 --- a/locales/en.json +++ b/locales/en.json @@ -53,5 +53,6 @@ "download_bad_status_code": "{url:s} returned status code {code:s}", "command_unknown": "Command '{command:s}' unknown ?", "warn_the_user_about_waiting_lock": "Another YunoHost command is running right now, we are waiting for it to finish before running this one", - "warn_the_user_about_waiting_lock_again": "Still waiting..." + "warn_the_user_about_waiting_lock_again": "Still waiting...", + "warn_the_user_that_lock_is_acquired": "the other command just complet, now starting this command" } diff --git a/moulinette/core.py b/moulinette/core.py index 4de9d0fc..aba06afb 100644 --- a/moulinette/core.py +++ b/moulinette/core.py @@ -504,6 +504,10 @@ class MoulinetteLock(object): # Wait before checking again time.sleep(self.interval) + # we have warned the user that we were waiting, for better UX also them + # that we have stop waiting and that the command is processing now + if warning_treshold != 15: + logger.warning(moulinette.m18n.g('warn_the_user_that_lock_is_acquired')) logger.debug('lock has been acquired') self._locked = True