[Fix] Fix connect: change sync to async
This commit is contained in:
parent
4bb5d43b6f
commit
be6f292aca
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user