[Mod] 改变Singleton的使用说明
This commit is contained in:
parent
0e67e75d6c
commit
70adba7637
@ -197,13 +197,11 @@ class BaseEngine(ABC):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class LogEngine(BaseEngine):
|
class LogEngine(BaseEngine, metaclass=Singleton):
|
||||||
"""
|
"""
|
||||||
Processes log event and output with logging module.
|
Processes log event and output with logging module.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__metaclass__ = Singleton
|
|
||||||
|
|
||||||
def __init__(self, main_engine: MainEngine, event_engine: EventEngine):
|
def __init__(self, main_engine: MainEngine, event_engine: EventEngine):
|
||||||
""""""
|
""""""
|
||||||
super(LogEngine, self).__init__(main_engine, event_engine, "log")
|
super(LogEngine, self).__init__(main_engine, event_engine, "log")
|
||||||
|
@ -14,10 +14,11 @@ from .object import BarData, TickData
|
|||||||
|
|
||||||
class Singleton(type):
|
class Singleton(type):
|
||||||
"""
|
"""
|
||||||
Singleton metaclass,
|
Singleton metaclass,
|
||||||
|
|
||||||
class A:
|
usage:
|
||||||
__metaclass__ = Singleton
|
class A(metaclass=Singleton):
|
||||||
|
...
|
||||||
"""
|
"""
|
||||||
_instances = {}
|
_instances = {}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user