fix: 重启后立即读库展示持仓,CTP异步重连不再阻塞
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+2
-3
@@ -11,7 +11,7 @@ from vnpy_bridge import ctp_try_auto_reconnect
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
RECONNECT_INTERVAL_SEC = 30
|
||||
RECONNECT_INTERVAL_SEC = 10
|
||||
|
||||
|
||||
def _auto_reconnect_enabled() -> bool:
|
||||
@@ -26,7 +26,6 @@ def start_ctp_reconnect_worker(*, get_mode_fn: Callable[[], str], interval: int
|
||||
"""定时检测 CTP 连接,断线后自动重连。"""
|
||||
|
||||
def _loop() -> None:
|
||||
time.sleep(5)
|
||||
while True:
|
||||
try:
|
||||
if _auto_reconnect_enabled():
|
||||
@@ -35,6 +34,6 @@ def start_ctp_reconnect_worker(*, get_mode_fn: Callable[[], str], interval: int
|
||||
logger.debug("CTP 连接正常 [%s]", mode)
|
||||
except Exception as exc:
|
||||
logger.warning("CTP reconnect worker: %s", exc)
|
||||
time.sleep(max(15, interval))
|
||||
time.sleep(max(5, interval))
|
||||
|
||||
threading.Thread(target=_loop, daemon=True, name="ctp-reconnect-worker").start()
|
||||
|
||||
Reference in New Issue
Block a user