From e4d9bd1e435417fa476f444d7d6cea69ff597ac7 Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Tue, 17 Aug 2021 20:19:09 +0300
Subject: [PATCH] Notifcation retries.

---
 mnpw/__init__.py | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/mnpw/__init__.py b/mnpw/__init__.py
index fbf7a91..51c3554 100644
--- a/mnpw/__init__.py
+++ b/mnpw/__init__.py
@@ -16,11 +16,16 @@ HOSTNAME = socket.gethostname()
 
 def notify(message):
     """Send a notification."""
-    r = requests.post(  # pylint: disable=invalid-name
-        "https://notify.shore.co.il/send", params={"message": message}
-    )
-    if not r.ok:
-        logging.error(f"Failed to send notification: {r.reason}.")
+    for _ in range(3):
+        r = requests.post(  # pylint: disable=invalid-name
+            "https://notify.shore.co.il/send", params={"message": message}
+        )
+        if r.ok:
+            return
+        logging.warning(
+            f"Failed to send notification: {r.reason}, will retry."
+        )
+        logging.error("Failed to send notification.")
 
 
 def main():  # noqa: MC0001
-- 
GitLab