mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-29 02:21:41 +00:00
improved singleton
This commit is contained in:
8
backend/app/classes/Singleton.py
Normal file
8
backend/app/classes/Singleton.py
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
class Singleton(type):
|
||||
_instances = {}
|
||||
|
||||
def __call__(cls, *args, **kwargs):
|
||||
if cls not in cls._instances:
|
||||
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
|
||||
return cls._instances[cls]
|
||||
Reference in New Issue
Block a user