fix: 重启后立即读库展示持仓,CTP异步重连不再阻塞

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-25 14:57:39 +08:00
parent 01de8dfb69
commit 7daed9bd3a
5 changed files with 111 additions and 38 deletions
+2 -3
View File
@@ -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()