Files
seedsigner/src/seedsigner/helpers/singleton.py
T
2021-08-03 16:15:20 -04:00

14 lines
441 B
Python

class Singleton:
_instance = None
def __init__(self):
# Singleton pattern must prevent normal instantiation
raise Exception("Cannot directly instantiate a Singleton. Access via get_instance()")
@classmethod
def get_instance(cls):
# This is the only way to access the one and only Controller
if cls._instance is None:
cls._instance = cls.__new__(cls)
return cls._instance