From 84e6eb277fa30f385b8b77476d13e5859f12bc47 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Wed, 18 Oct 2017 10:38:41 +0800 Subject: [PATCH] =?UTF-8?q?[Mod]Close=20#540=EF=BC=8C=E5=AE=9E=E7=8E=B0Log?= =?UTF-8?q?Engine=E7=9A=84=E5=8D=95=E4=BE=8B=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/trader/vtEngine.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vnpy/trader/vtEngine.py b/vnpy/trader/vtEngine.py index 495cc435..598e8bb1 100644 --- a/vnpy/trader/vtEngine.py +++ b/vnpy/trader/vtEngine.py @@ -518,6 +518,16 @@ class LogEngine(object): LEVEL_WARN = logging.WARN LEVEL_ERROR = logging.ERROR LEVEL_CRITICAL = logging.CRITICAL + + # 单例对象 + instance = None + + #---------------------------------------------------------------------- + def __new__(cls, *args, **kwargs): + """创建对象,保证单例""" + if not cls.instance: + cls.instance = super(LogEngine, cls).__new__(cls, *args, **kwargs) + return cls.instance #---------------------------------------------------------------------- def __init__(self):