milvus/utils/__init__.py
2019-09-21 11:08:14 +08:00

11 lines
250 B
Python

from functools import wraps
def singleton(cls):
instances = {}
@wraps(cls)
def getinstance(*args, **kw):
if cls not in instances:
instances[cls] = cls(*args, **kw)
return instances[cls]
return getinstance