diff --git a/services/tasks.py b/services/tasks.py index 12c138a..74ad36f 100644 --- a/services/tasks.py +++ b/services/tasks.py @@ -895,7 +895,13 @@ def run_task(user_id, account_id, browse_type, enable_screenshot=True, source="m _emit("account_update", account.to_dict(), room=f"user_{user_id}") def delayed_retry_submit(): - if account.should_stop: + # 重新获取最新的账户对象,避免使用闭包中的旧对象 + fresh_account = safe_get_account(user_id, account_id) + if not fresh_account: + log_to_client("自动重试取消: 账户不存在", user_id, account_id) + return + if fresh_account.should_stop: + log_to_client("自动重试取消: 任务已被停止", user_id, account_id) return log_to_client(f"🔄 开始第 {retry_count + 1} 次自动重试...", user_id, account_id) ok, msg = submit_account_task(