Skip to content

Commit 19064fa

Browse files
authored
Multithread issue with singleton
1 parent f8742ca commit 19064fa

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

narps_open/utils/singleton.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ class SingletonMeta(type):
1919

2020
def __call__(cls, *args, **kwargs):
2121
""" Creating only one instance for the class 'cls' """
22-
with cls._lock:
23-
if cls not in cls._instances:
22+
if cls not in cls._instances:
23+
with cls._lock:
2424
instance = super().__call__(*args, **kwargs)
2525
cls._instances[cls] = instance
26+
2627
return cls._instances[cls]

0 commit comments

Comments
 (0)