From 9410775fb36c0da5de87da8fc01e67a395da757c Mon Sep 17 00:00:00 2001 From: nanoric Date: Fri, 15 Mar 2019 00:01:00 -0400 Subject: [PATCH] [Add] OesGateway: TD API: Reconnect: Reduce CPU usage. --- vnpy/gateway/oes/oes_td.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/vnpy/gateway/oes/oes_td.py b/vnpy/gateway/oes/oes_td.py index b7ac7656..78871396 100644 --- a/vnpy/gateway/oes/oes_td.py +++ b/vnpy/gateway/oes/oes_td.py @@ -1,3 +1,4 @@ +import time from dataclasses import dataclass from datetime import datetime, timedelta, timezone from gettext import gettext as _ @@ -423,12 +424,10 @@ class OesTdApi: def _reconnect_ord_channel(self): with self._reconnect_lock: # prevent spawning multiple reconnect thread - if OesApi_IsValidOrdChannel(self._env.ordChannel): - return - self.gateway.write_log(_("正在重新连接到交易下单通道")) - while not OesApi_IsValidOrdChannel(self._env.ordChannel): - self._connect_ord_channel() + while not self._connect_ord_channel(): + time.sleep(1) + self.gateway.write_log(_("成功重新连接到交易下单通道")) def _schedule_reconnect_ord_channel(self):