Feature 10296 Pip Standardization
[osm/LCM.git] / osm_lcm / prometheus.py
index 8de81d7..5afa496 100644 (file)
@@ -24,6 +24,7 @@ import yaml
 import os
 from osm_lcm.lcm_utils import LcmException
 from osm_common.dbbase import DbException
+from osm_lcm.data_utils.database.database import Database
 from jinja2 import Template, TemplateError, TemplateNotFound, TemplateSyntaxError
 
 __author__ = "Alfonso Tierno <alfonso.tiernosepulveda@telefonica.com>"
@@ -53,9 +54,9 @@ class Prometheus:
 
     PROMETHEUS_LOCKED_TIME = 120
 
-    def __init__(self, config, worker_id, db, loop, logger=None):
+    def __init__(self, config, worker_id, loop, logger=None):
         self.worker_id = worker_id
-        self.db = db
+        self.db = Database().instance.db
         self.loop = loop
         self.logger = logger or logging.getLogger("lcm.prometheus")
         self.server = config["uri"]
@@ -101,10 +102,10 @@ class Prometheus:
         :param remove_jobs: list with jobs to remove [job_id_1, job_id_2]
         :return: result. If false prometheus denies this configuration. Exception on error
         """
-        for retry in range(4):
+        for retry in range(20):
             result = True
             if retry:  # first time do not wait
-                await asyncio.sleep(self.PROMETHEUS_LOCKED_TIME / 2, loop=self.loop)
+                await asyncio.sleep(4 + retry, loop=self.loop)
 
             # lock database
             now = time()