mirror of
https://github.com/craigerl/aprsd.git
synced 2025-07-09 12:25:16 -04:00
Update StatsStore to use existing lock
The base class for StatsStore already creates a lock, use that instead.
This commit is contained in:
parent
19c12e70f3
commit
227ddbf148
@ -1,8 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
import threading
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import wrapt
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
from aprsd.stats import collector
|
from aprsd.stats import collector
|
||||||
@ -10,18 +8,15 @@ from aprsd.threads import APRSDThread
|
|||||||
from aprsd.utils import objectstore
|
from aprsd.utils import objectstore
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
LOG = logging.getLogger("APRSD")
|
LOG = logging.getLogger('APRSD')
|
||||||
|
|
||||||
|
|
||||||
class StatsStore(objectstore.ObjectStoreMixin):
|
class StatsStore(objectstore.ObjectStoreMixin):
|
||||||
"""Container to save the stats from the collector."""
|
"""Container to save the stats from the collector."""
|
||||||
|
|
||||||
lock = threading.Lock()
|
|
||||||
data = {}
|
|
||||||
|
|
||||||
@wrapt.synchronized(lock)
|
|
||||||
def add(self, stats: dict):
|
def add(self, stats: dict):
|
||||||
self.data = stats
|
with self.lock:
|
||||||
|
self.data = stats
|
||||||
|
|
||||||
|
|
||||||
class APRSDStatsStoreThread(APRSDThread):
|
class APRSDStatsStoreThread(APRSDThread):
|
||||||
@ -31,7 +26,7 @@ class APRSDStatsStoreThread(APRSDThread):
|
|||||||
save_interval = 10
|
save_interval = 10
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__("StatsStore")
|
super().__init__('StatsStore')
|
||||||
|
|
||||||
def loop(self):
|
def loop(self):
|
||||||
if self.loop_count % self.save_interval == 0:
|
if self.loop_count % self.save_interval == 0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user