This commit is contained in:
LanWeiFRJ
2025-10-29 14:02:04 +08:00
parent c6b8c4bbd8
commit e334c4f764
52 changed files with 12251 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
import threading
def singleton(cls):
instances = {}
lock = threading.Lock()
def get_instance(*args, **kwargs):
if cls not in instances:
with lock:
if cls not in instances:
instances[cls] = cls(*args, **kwargs)
return instances[cls]
return get_instance