This repository has been archived on 2024-09-10. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Douyin_Web_Live/common/singleton.py

10 lines
287 B
Python

class Singleton(type):
"""
单例模式(以metaclass方式实现)
"""
_instances = {}
def __call__(cls, *args, **kwargs):
if cls not in cls._instances:
cls._instances[cls] = super().__call__(*args, **kwargs)
return cls._instances[cls]