Resolved bug 1719 - POL hangs waiting for webhook response
[osm/POL.git] / osm_policy_module / alarming / service.py
index 13433ba..a938234 100644 (file)
@@ -218,6 +218,7 @@ class AlarmingService:
             database.db.close()
 
     async def handle_alarm(self, alarm_uuid: str, status: str, payload: dict):
+        alert_timeout = int(self.conf.get('alert', 'timeout'))
         database.db.connect()
         try:
             with database.db.atomic():
@@ -234,9 +235,9 @@ class AlarmingService:
                             status,
                         )
                         try:
-                            requests.post(url=action.url, json=json.dumps(payload))
+                            requests.post(url=action.url, json=json.dumps(payload), timeout=alert_timeout)
                         except RequestException as e:
-                            log.info("Error connecting to url %s", action.url)
+                            log.info("Error: RequestException while connecting to url %s", action.url)
                             log.debug("RequestException %s", e)
                         except ConnectionError:
                             log.exception("Error connecting to url %s", action.url)