From be6f292aca88e4cb8b6e851a6ef778bcd624786b Mon Sep 17 00:00:00 2001 From: nanoric Date: Mon, 4 Mar 2019 02:17:20 -0400 Subject: [PATCH] [Fix] Fix connect: change sync to async --- vnpy/gateway/oes/oes_gateway.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vnpy/gateway/oes/oes_gateway.py b/vnpy/gateway/oes/oes_gateway.py index c2069f93..83f9b492 100644 --- a/vnpy/gateway/oes/oes_gateway.py +++ b/vnpy/gateway/oes/oes_gateway.py @@ -3,6 +3,7 @@ """ import hashlib import os +from threading import Thread from vnpy.trader.gateway import BaseGateway from vnpy.trader.object import (AccountData, CancelRequest, ContractData, OrderData, OrderRequest, @@ -54,6 +55,9 @@ class OesGateway(BaseGateway): self.td_api = OesTdApi(self) def connect(self, setting: dict): + return self._connect_async(setting) + + def _connect_sync(self, setting: dict): """""" if not setting['password'].startswith("md5:"): setting['password'] = "md5:" + hashlib.md5(setting['password'].encode()).hexdigest() @@ -86,6 +90,9 @@ class OesGateway(BaseGateway): self.md_api.connect(str(config_path)) self.md_api.start() + def _connect_async(self, setting: dict): + Thread(target=self._connect_sync, args=(setting, )).start() + def subscribe(self, req: SubscribeRequest): """""" self.md_api.subscribe(req)