From 4a19a60b44a81ab5f80e4547a05b64694b169154 Mon Sep 17 00:00:00 2001
From: Kay0u <pierre@kayou.io>
Date: Wed, 10 Mar 2021 11:24:11 +0100
Subject: [PATCH] dirty patch to wait for services to finish reloading

---
 src/yunohost/app.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/yunohost/app.py b/src/yunohost/app.py
index fadc16b6e..9d53df815 100644
--- a/src/yunohost/app.py
+++ b/src/yunohost/app.py
@@ -3465,6 +3465,14 @@ def _assert_system_is_sane_for_app(manifest, when):
     if "fail2ban" not in services:
         services.append("fail2ban")
 
+    # Wait if a service is reloading
+    test_nb = 0
+    while test_nb < 10:
+        if not any(s for s in services if service_status(s)["status"] == "reloading"):
+            break
+        time.sleep(0.5)
+        test_nb+=1
+
     # List services currently down and raise an exception if any are found
     faulty_services = [s for s in services if service_status(s)["status"] != "running"]
     if faulty_services: