milvus/shards/utils/__init__.py
2019-10-21 16:21:32 +08:00

12 lines
251 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