From 1d6506c5f3a57b37e30351c7b7e414351a54c867 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Thu, 11 Apr 2019 16:54:43 +0800 Subject: [PATCH] [Del]remove Singleton --- vnpy/trader/engine.py | 4 ++-- vnpy/trader/utility.py | 19 ------------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/vnpy/trader/engine.py b/vnpy/trader/engine.py index af136dab..2d4a98e0 100644 --- a/vnpy/trader/engine.py +++ b/vnpy/trader/engine.py @@ -24,7 +24,7 @@ from .event import ( from .gateway import BaseGateway from .object import CancelRequest, LogData, OrderRequest, SubscribeRequest from .setting import SETTINGS -from .utility import Singleton, get_folder_path +from .utility import get_folder_path class MainEngine: @@ -197,7 +197,7 @@ class BaseEngine(ABC): pass -class LogEngine(BaseEngine, metaclass=Singleton): +class LogEngine(BaseEngine): """ Processes log event and output with logging module. """ diff --git a/vnpy/trader/utility.py b/vnpy/trader/utility.py index 6f023259..1f40aa77 100644 --- a/vnpy/trader/utility.py +++ b/vnpy/trader/utility.py @@ -12,25 +12,6 @@ import talib from .object import BarData, TickData -class Singleton(type): - """ - Singleton metaclass, - - usage: - class A(metaclass=Singleton): - ... - """ - _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] - - def _get_trader_dir(temp_name: str): """ Get path where trader is running in.