diff --git a/aprsd/threads/stats.py b/aprsd/threads/stats.py index 6058781..54d789a 100644 --- a/aprsd/threads/stats.py +++ b/aprsd/threads/stats.py @@ -1,8 +1,6 @@ import logging -import threading import time -import wrapt from oslo_config import cfg from aprsd.stats import collector @@ -10,18 +8,15 @@ from aprsd.threads import APRSDThread from aprsd.utils import objectstore CONF = cfg.CONF -LOG = logging.getLogger("APRSD") +LOG = logging.getLogger('APRSD') class StatsStore(objectstore.ObjectStoreMixin): """Container to save the stats from the collector.""" - lock = threading.Lock() - data = {} - - @wrapt.synchronized(lock) def add(self, stats: dict): - self.data = stats + with self.lock: + self.data = stats class APRSDStatsStoreThread(APRSDThread): @@ -31,7 +26,7 @@ class APRSDStatsStoreThread(APRSDThread): save_interval = 10 def __init__(self): - super().__init__("StatsStore") + super().__init__('StatsStore') def loop(self): if self.loop_count % self.save_interval == 0: