fix: 手续费同步改为后台执行,避免阻塞 Web 请求

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-24 13:45:39 +08:00
parent e01c011df5
commit 1d95950b5c
3 changed files with 47 additions and 2 deletions
+8 -2
View File
@@ -1560,7 +1560,12 @@ def api_contract_profile():
@require_nav("fees")
def fees():
from trading_context import get_trading_mode
from ctp_fee_worker import try_daily_ctp_fee_sync, get_fee_last_sync, fees_synced_today
from ctp_fee_worker import (
schedule_ctp_fee_sync,
get_fee_last_sync,
fees_synced_today,
fee_sync_in_progress,
)
from vnpy_bridge import ctp_status
mode = get_trading_mode(get_setting)
@@ -1568,7 +1573,7 @@ def fees():
action = request.form.get("action")
if action == "sync_ctp":
force = request.form.get("force") == "1"
count, msg = try_daily_ctp_fee_sync(
_, msg = schedule_ctp_fee_sync(
mode,
get_setting=get_setting,
set_setting=set_setting,
@@ -1586,6 +1591,7 @@ def fees():
fee_counts=fee_counts,
fee_last_sync=get_fee_last_sync(get_setting),
fee_synced_today=fees_synced_today(get_setting),
fee_sync_running=fee_sync_in_progress(),
ctp_connected=bool(ctp_st.get("connected")),
)