fix: avoid Binance /trade hang when exchange API is unreachable.

Add a short ccxt timeout and isolate orphan live-position loading so page render can fail soft.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-17 18:04:25 +08:00
parent 30a2efce3f
commit 690635b59f
+5 -1
View File
@@ -483,6 +483,7 @@ app.config["UPLOAD_FOLDER"] = UPLOAD_FOLDER
# Binance USDT 本位永续(ccxt unified: defaultType=swap)
exchange = ccxt.binance({
"enableRateLimit": True,
"timeout": 5000,
"options": {
"defaultType": "swap",
"defaultMarginMode": _BINANCE_DEFAULT_MARGIN_MODE,
@@ -7315,7 +7316,10 @@ def render_main_page(page="trade", embed_mode=None):
)
orphan_live_positions = []
if plan.orphan_live and not order_list and exchange_private_api_configured():
orphan_live_positions = list_orphan_live_positions(conn)
try:
orphan_live_positions = list_orphan_live_positions(conn)
except Exception:
orphan_live_positions = []
conn.close()
from lib.instance.instance_embed_lib import embed_context_extras
from lib.instance.instance_settings_lib import settings_page_context