You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
438 B
22 lines
438 B
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
# @Time : 2023/4/12 15:09
|
|
# @Author : old tom
|
|
# @File : fu_function.py
|
|
# @Project : futool-tiny-datahub
|
|
# @Desc :
|
|
def singleton(cls):
|
|
"""
|
|
单例装饰器
|
|
:param cls:
|
|
:return:
|
|
"""
|
|
_instance = {}
|
|
|
|
def inner(*args, **kwargs):
|
|
if cls not in _instance:
|
|
_instance[cls] = cls(*args, **kwargs)
|
|
return _instance[cls]
|
|
|
|
return inner
|