T-578 更新失败关闭新建商品页

This commit is contained in:
chengma
2026-07-09 21:08:42 +08:00
parent 7c606e860e
commit 65a01c35e8
5 changed files with 137 additions and 14 deletions
+7 -4
View File
@@ -1509,19 +1509,22 @@ def apply_task(account, task, close_success_tab=False, on_step=None, bring_to_fr
_notify_apply_step(on_step, current_step, "failed", str(exc))
return {"committed": False, "error": str(exc)}
finally:
_close_applied_product(cdp, close_success_tab=close_success_tab and committed)
_close_applied_product(cdp, committed=committed, close_success_tab=close_success_tab)
def _close_applied_product(cdp, close_success_tab=False):
def _close_applied_product(cdp, committed=False, close_success_tab=False):
target_id = getattr(cdp, "target_id", None)
created_by_app = bool(getattr(cdp, "created_by_app", False))
host = getattr(cdp, "cdp_host", None)
should_close_tab = bool(created_by_app and target_id and (not committed or close_success_tab))
should_wait_before_close = bool(committed and close_success_tab)
try:
cdp.close()
finally:
if close_success_tab and created_by_app and target_id:
if should_close_tab:
try:
time.sleep(2)
if should_wait_before_close:
time.sleep(2)
close_tab(target_id, host=host)
except Exception:
pass