From 384a4f40fe0c023c997f265b9d1933cd9223dd0c Mon Sep 17 00:00:00 2001 From: James Muscat Date: Mon, 13 Apr 2015 18:28:50 +0100 Subject: [PATCH] ...except that tally should require the lock. --- src/eddn/StatsCollector.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/eddn/StatsCollector.py b/src/eddn/StatsCollector.py index 9c3cacb..559e02c 100644 --- a/src/eddn/StatsCollector.py +++ b/src/eddn/StatsCollector.py @@ -51,10 +51,11 @@ class StatsCollector(Thread): self.outboundMessages += 1 def tally(self, key): - if key not in self.current: - self.current[key] = 1 - else: - self.current[key] += 1 + with self.lock: + if key not in self.current: + self.current[key] = 1 + else: + self.current[key] += 1 def getInboundCount(self, minutes): return sum(islice(self.inboundHistory, 0, min(minutes, self.max_minutes)))