singleton fix
This commit is contained in:
parent
635feb3532
commit
6c525477d9
3 changed files with 15 additions and 11 deletions
12
src/util.py
12
src/util.py
|
@ -31,7 +31,11 @@ def get_style(style):
|
|||
|
||||
class Singleton(object):
|
||||
|
||||
def __new__(cls, *args):
|
||||
if not hasattr(cls, 'instance'):
|
||||
cls.instance = super(Singleton, cls,).__new__(cls, *args)
|
||||
return cls.instance
|
||||
def __new__(cls, *args, **kwargs):
|
||||
if not hasattr(cls, '_instance'):
|
||||
cls._instance = super(Singleton, cls).__new__(cls, *args, **kwargs)
|
||||
return cls._instance
|
||||
|
||||
@classmethod
|
||||
def get_instance(cls):
|
||||
return cls._instance
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue