Skip to content

Commit 362ef84

Browse files
authored
Update api.py
为API添加一个deadline参数,默认为60秒,
1 parent 1734bd5 commit 362ef84

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tqsdk/api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class TqApi(TqBaseApi):
9191
"""
9292

9393
def __init__(self, account: Optional[Union[TqMultiAccount, UnionTradeable]] = None,
94-
auth: Union[TqAuth, str, None] = None,
94+
auth: Union[TqAuth, str, None] = None,deadline: Optional[float] = 60,
9595
url: Optional[str] = None, backtest: Union[TqBacktest, TqReplay, None] = None,
9696
web_gui: Union[bool, str] = False, debug: Union[bool, str, None] = None,
9797
loop: Optional[asyncio.AbstractEventLoop] = None, disable_print: bool = False, _stock: bool = True,
@@ -290,12 +290,12 @@ def __init__(self, account: Optional[Union[TqMultiAccount, UnionTradeable]] = No
290290
self._setup_connection() # 初始化通讯连接
291291

292292
# 等待初始化完成
293-
deadline = time.time() + 60
293+
_deadline = time.time() + deadline
294294
try:
295295
# 多账户时,所有账户需要初始化完成
296296
trade_more_data = True
297297
while self._data.get("mdhis_more_data", True) or trade_more_data:
298-
if not self.wait_update(deadline=deadline): # 等待连接成功并收取截面数据
298+
if not self.wait_update(_deadline=deadline): # 等待连接成功并收取截面数据
299299
raise TqTimeoutError("接收数据超时,请检查客户端及网络是否正常")
300300
trade_more_data = self._account._get_trade_more_data(self._data)
301301
except:

0 commit comments

Comments
 (0)