Skip to content

Commit f580147

Browse files
committed
use itertools.count
1 parent 32b41bc commit f580147

File tree

1 file changed

+5
-6
lines changed
  • localstack-core/localstack/utils/analytics

1 file changed

+5
-6
lines changed

localstack-core/localstack/utils/analytics/usage.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import datetime
22
import math
3-
import threading
43
from collections import defaultdict
4+
from itertools import count
55
from typing import Any
66

77
from localstack import config
@@ -31,19 +31,18 @@ class UsageSetCounter:
3131
"""
3232

3333
state: dict[str, int]
34+
_counter: dict[str, count]
3435
namespace: str
35-
_lock: threading.RLock
3636

3737
def __init__(self, namespace: str):
3838
self.enabled = True
39-
self.state = defaultdict(int)
39+
self.state = {}
40+
self._counter = defaultdict(count)
4041
self.namespace = namespace
41-
self._lock = threading.RLock()
4242

4343
def record(self, value: str):
4444
if self.enabled:
45-
with self._lock:
46-
self.state[value] += 1
45+
self.state[value] = next(self._counter[value])
4746

4847
def aggregate(self) -> dict:
4948
return self.state

0 commit comments

Comments
 (0)