Skip to content

Commit f04e751

Browse files
tweak sequence generator (#2)
1 parent 058402d commit f04e751

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

tests/utils.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,18 @@ def __init__(self):
1111
self._counter = 1
1212

1313
def __new__(cls):
14-
with cls._lock:
15-
if cls._instance is None:
16-
cls._instance = super().__new__(cls)
17-
cls._instance._counter = 1
18-
return cls._instance
14+
if cls._instance is None:
15+
with cls._lock:
16+
if cls._instance is None:
17+
cls._instance = super().__new__(cls)
18+
cls._instance._counter = 1
19+
return cls._instance
1920

2021
def next(self):
2122
with self._lock:
2223
current = self._counter
2324
self._counter += 1
24-
return current
25+
return current
2526

2627

2728
seq = SequenceGenerator()

0 commit comments

Comments
 (0)